我在尝试加入 3 个表的 LINQ 查询时遇到问题,其中一个表充当过滤器。当我只使用其中一个连接运行查询时,我得到了预期的记录数,但是当我添加第二个连接时,查询会过滤掉我不想要的其他记录。2个查询粘贴在下面......有人能看到我在哪里出错了吗?谢谢!
使用单个连接(预期结果):
Dim Report = From Filter In FilterTable _
Join EDTK In eDTKBase _
On Filter.PLI_Code Equals EDTK.eDTK_PLI _
Select Filter.PLI_Code, _
EDTK.eDTK_Instance, _
EDTK.eDTK_PLI_Name, _
EDTK.eDTK_PDP_Code, _
EDTK.PDD_PDP_Description
有 2 个连接:
Dim Report= From Filter In FilterTable_
Join EDTK In eDTKBase _
On Filter.PLI_Code Equals EDTK.eDTK_PLI _
Join PLI In ProdBase _
On Filter.PLI_Code Equals PLI.Siebel_PLI _
Select Filter.PLI_Code, _
EDTK.eDTK_Instance, _
EDTK.eDTK_PLI_Name, _
PLI.Siebel_PLI, _
PLI.Siebel_PLI_Name, _
EDTK.eDTK_PDP_Code, _
PLI.Siebel_PDP_Code, _
EDTK.PDD_PDP_Description
好的,所以我使用左连接将查询更改为一个,但我仍然会过滤掉记录;我的联接的编写方式可能有问题吗?
Dim EDTKMultPDPtoPLIRpt = From Filter In EDTKMultPDPtoPLIFilter _
Group Join EDTK In eDTKBase _
On Filter.PLI_Code Equals EDTK.eDTK_PLI _
Into g = Group _
From EDTK In g _
Group Join PLI In ProdBase _
On EDTK.eDTK_PLI Equals PLI.Siebel_PLI _
Into h = Group _
From PLI In h _
Select Filter.PLI_Code, _
EDTK.eDTK_Instance, _
EDTK.eDTK_PLI_Name, _
PLI.Siebel_PLI, _
PLI.Siebel_PLI_Name, _
EDTK.eDTK_PDP_Code, _
PLI.Siebel_PDP_Code, _
EDTK.PDD_PDP_Description