Linq2Sql中的交叉连接问题

3

我有以下的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

出现笛卡尔积(cross join)的原因不明,我认为应该是内连接(inner join)。如果我在where子句中使用多个From并进行键比较,则仍然会得到相同的结果。我做错了什么?

3
你的第一步可能是检查生成的 SQL。http://www.davidhayden.com/blog/dave/archive/2007/08/17/DataContextLogLoggingLINQToSQLOutputConsoleDebuggerOuputWindow.aspx - Keith
1个回答

0

我想这会对你有所帮助:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接