我正在尝试加入以下查询,但tagNumbers是一个List,而其他2是DbEntities。
var x = (from e in dbContext.TagCollections
join m in dbContext.MapTagEntities on e.TagId equals m.TagId
where m.StartDate < DateTime.UtcNow
&& m.EndDate > DateTime.UtcNow && e.TagNumber == tagNumber
join t in tagNumbers on t equals e.TagNumber
select m
).ToList();
我收到编译错误。是否可以加入这些查询。
答案 0 :(得分:3)
感谢King King的暗示。操作数的位置在这里很重要。 e.TagNumber equals t
var x = (from e in dbContext.TagCollections
join m in dbContext.MapTagEntities on e.TagId equals m.TagId
where m.StartDate < DateTime.UtcNow
&& m.EndDate > DateTime.UtcNow && e.TagNumber == tagNumber
join t in tagNumbers on e.TagNumber equals t
select m
).ToList();