【问题标题】:Cross join problem with linq2sqllinq2sql 的交叉连接问题
【发布时间】:2011-09-05 03:44:05
【问题描述】:

我有以下 LINQ2SQL 查询:

From pc In DBContext.ProcessCodes
Join c In DBContext.Cells On pc.idCell Equals c.idCell
    Where pc.idType = "Cars" AndAlso
          pc.Active = True AndAlso
          c.Active = True
    Select c

由于某种原因,当我认为我应该获得内部联接时,我得到了交叉联接(笛卡尔积)。如果我在 where 中使用键比较执行多个​​ From,我会得到同样的结果。

我做错了什么?

【问题讨论】:

标签: vb.net visual-studio-2010 linq-to-sql


【解决方案1】:

我认为这对你有帮助:

From pc In DBContext.ProcessCodes 
From c In DBContext.Cells
Where pc.idType = "Cars" AndAlso           
      pc.Active = True AndAlso
      c.Active = True     
Select c 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-24
    • 2011-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    相关资源
    最近更新 更多