在where条件中如何检查linq left join条件中的null值
我正在编写linq查询,若右表中并没有记录,则需要从左表always事件中获取记录。我为此编写了linq查询。正确的表可能由空值组成。在这种情况下,我得到了一个错误。 如何在where子句中检查on子句中的空条件。如果我使用where子句检查NULL,它会得到零条记录,但我需要所有的左表记录在where条件中如何检查linq left join条件中的null值,linq,linq-to-sql,Linq,Linq To Sql,我正在编写linq查询,若右表中并没有记录,则需要从左表always事件中获取记录。我为此编写了linq查询。正确的表可能由空值组成。在这种情况下,我得到了一个错误。 如何在where子句中检查on子句中的空条件。如果我使用where子句检查NULL,它会得到零条记录,但我需要所有的左表记录 join sfs in db.SubmissionFileUploadSummaries on new { sub.CollectionId, districtid, tbl.Tablename } eq
join sfs in db.SubmissionFileUploadSummaries on new { sub.CollectionId, districtid, tbl.Tablename } equals new { CollectionId = (int)sfs.CollectionId, districtid = (int)sfs.OrganizationId, Tablename = sfs.TableName }
into sfslist
from sfssub in sfslist.DefaultIfEmpty()
where sfssub.CollectionId!=null
保持
左外部联接
语义的一般规则是在联接之前应用右表过滤器:
join sfs in (from sfs in db.SubmissionFileUploadSummaries
where sfs.CollectionId != null
select sfs)
on new { sub.CollectionId, districtid, tbl.Tablename }
equals new { CollectionId = (int)sfs.CollectionId, districtid = (int)sfs.OrganizationId, Tablename = sfs.TableName }
into sfslist
from sfssub in sfslist.DefaultIfEmpty()
保持
左外部联接
语义的一般规则是在联接之前应用右表过滤器:
join sfs in (from sfs in db.SubmissionFileUploadSummaries
where sfs.CollectionId != null
select sfs)
on new { sub.CollectionId, districtid, tbl.Tablename }
equals new { CollectionId = (int)sfs.CollectionId, districtid = (int)sfs.OrganizationId, Tablename = sfs.TableName }
into sfslist
from sfssub in sfslist.DefaultIfEmpty()