DBLinq不生成where子句 [英] DBLinq not generating where clause

查看:99
本文介绍了DBLinq不生成where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MySQL和Postgresql从SVN Trunk中测试DBLinq-0.18和DBLinq.我仅使用一个非常简单的查询,但在两个数据库上,DBLinq均未生成Where子句.我已经通过在Postgresql上打开语句日志记录来检查DBLinq正在发送的请求,从而确认了这一点.

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.

我的Linq查询是:

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;

查询正常,但是DBLinq生成的SQL格式为:

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

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

没有Where子句,这意味着DBLinq必须在运行Linq查询之前将整个表拉低.

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

任何人都有使用DBLinq的经验,并且知道我可能做错了什么吗?

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

推荐答案

我发现了问题,与DBLinq无关.

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

我一直在测试IronRuby的某些功能,并且其中有一个名为Microsoft.Scripting.Core的程序集,该程序集与System.Data.Linq命名空间重复(为什么这样做,我不知道).

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).

通过引用Microsoft.Scripting.Core程序集,我的测试DBLinq应用程序可以编译并运行良好,但SQL上缺少where子句.删除程序集引用会导致正确生成where子句.

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.

这篇关于DBLinq不生成where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆