DBLinq not generating where clause

送分小仙女□ 提交于 2019-12-07 16:12:33

问题


I'm testing out DBLinq-0.18 and DBLinq from SVN Trunk with MySQL and Postgresql. I'm only using a very simple query but on both database DBLinq is not generating a Where clause. I have confirmed this by turning on statement logging on Postgresql to check exactly what request DBLinq is sending.

My Linq query is:

MyDB db = new MyDB(new NpgsqlConnection("Database=database;Host=localhost;User Id=postgres;Password=password"));

var customers = from customer in db.Customers
                where customer.CustomerUserName == "test"
                select customer;

The query works ok but the SQL generated by DBLinq is of the form:

select customerusername, customerpassword .... from public.customers

There is no Where clause which means DBLinq must be pulling the whole table down before running the Linq query.

Has anyone had any experience with DBLinq and know what I could be doing wrong?


回答1:


I found the problem and it's nothing to do with DBLinq.

I had been testing some stuff out from IronRuby and within that there is an assembly called Microsoft.Scripting.Core which duplicates the System.Data.Linq namespace (why it does that I don't know).

With a reference to the Microsoft.Scripting.Core assembly my test DBLinq app would compile and run fine but would have the where clause missing on the SQL. Removing the assembly reference resulted in the where clause correctly being generated.




回答2:


I'd avoid using DBLinq for production code... many of Linq-To-SQL's features aren't implemented, and walking through the source code shows a low level of maturity... many of the methods are not implemented or marked as "unterminated".

...you've been warned!



来源:https://stackoverflow.com/questions/760665/dblinq-not-generating-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!