我有以下查询,问题是如果找不到匹配则返回所有结果。任何人都可以看到我出错的地方吗?
var searchResults = (from gId in dc.tbl1
join data in dc.tbl2 on gId.ID equals data.UserId into joinTbls
from data in joinTbls.DefaultIfEmpty()
where (data.OrderId == orderId) ||
(data.CardHolderName == cardHolderName) ||
(gId.Email == emailAddress) ||
(gId.FirstName == firstName) ||
(gId.LastName == lastName) ||
((IdGuid == null || gId.ID == IdGuid))
我认为这与某些事情有关:
from data in joinTbls.DefaultIfEmpty()
但我不确定如何解决它。
答案 0 :(得分:0)
IMO是因为你的Where子句中有“OR”(||)。尝试将其替换为“AND”(&&)
很高兴帮助