代码之家  ›  专栏  ›  技术社区  ›  sipsorcery

DBLinq未生成WHERE子句

  •  3
  • sipsorcery  · 技术社区  · 15 年前

    我正在用MySQL和PostgreSQL从SVN主干测试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的经验,知道我可能做错什么?

    2 回复  |  直到 14 年前
        1
  •  1
  •   sipsorcery    15 年前

    我发现了问题,这与DBLinq无关。

    我从IronRuby中测试了一些东西,其中有一个名为microsoft.scripting.core的程序集,它复制了system.data.linq名称空间(我不知道为什么会这样做)。

    通过引用microsoft.scripting.core程序集,我的测试dblinq应用程序将编译并运行良好,但SQL上缺少WHERE子句。删除程序集引用导致正确生成WHERE子句。

        2
  •  0
  •   Mark    15 年前

    我会避免在生产代码中使用dblinq…很多linq-to-sql的特性都没有实现,并且遍历源代码显示出很低的成熟度…许多方法没有实现或标记为“未终止”。

    …有人警告过你!