2011-05-31 44 views
4

加入的问题,我有以下LINQ2SQL查询:十字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 

出于某种原因,我得到一个交叉连接(笛卡尔乘积)时,我想我应该得到一个内部联接。如果我在多个From中进行关键比较,我会得到同样的结果。

我在做什么错?

+3

第一步可能是检查出生成的SQL。 http://www.davidhayden.com/blog/dave/archive/2007/08/17/DataContextLogLoggingLINQToSQLOutputConsoleDebuggerOuputWindow.aspx – Keith 2011-06-03 20:22:51

回答

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