DBLinq 不生成 where 子句
我正在使用 MySQL 和 Postgresql 从 SVN Trunk 测试 DBLinq-0.18 和 DBLinq。 我只使用一个非常简单的查询,但在两个数据库上 DBLinq 都没有生成Where 子句。 我通过打开 Postgresql 上的语句日志记录来准确检查 DBLinq 发送的请求来确认这一点。
我的 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 的形式为:
select customerusername, customerpassword .... from public.customers
没有Where 子句,这意味着 DBLinq 必须在运行 Linq 查询之前拉取整个表。
有没有人有过 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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现这个问题与DBLinq无关。
我一直在测试 IronRuby 中的一些东西,其中有一个名为 Microsoft.Scripting.Core 的程序集,它复制了 System.Data.Linq 命名空间(我不知道为什么这样做)。
通过引用 Microsoft.Scripting.Core 程序集,我的测试 DBLinq 应用程序可以正常编译并运行,但 SQL 上缺少 where 子句。 删除程序集引用会导致正确生成 where 子句。
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.
我会避免在生产代码中使用 DBLinq...Linq-To-SQL 的许多功能都未实现,并且浏览源代码显示成熟度较低...许多方法未实现或标记为“未终止”。
……你已被警告过!
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!