我遇到linq查询问题。我正在加入两个表,但where子句被完全忽略了。
using (var db = new Context())
{
var count = (from c in db.PERSON
join dt in db.DATA_INPUT_CHANGE_LOG
on c.DataInputTypeId equals dt.DataInputTypeId
join x in db.DATA_INPUT_CHANGE_LOG
on c.Id equals x.DataItemId
where c.PersonId == p1Id &&
c.RefPersonId == p2Id &&
c.RelationshipId == rId
where x.Approved
where x.Checked
where x.Hidden == false
select c).Count();
return count > 0;
}
在此特定查询中,x.Approved
,x.Checked
和x.Hidden == false
where子句将被完全忽略。
有人能指出我正确的方向吗?
答案 0 :(得分:-1)
您的语法不正确。你应该只有一个where子句。见下文:
var count = (from c in db.PERSON
join dt in db.DATA_INPUT_CHANGE_LOG
on c.DataInputTypeId equals dt.DataInputTypeId
join x in db.DATA_INPUT_CHANGE_LOG
on c.Id equals x.DataItemId
where c.PersonId == p1Id &&
c.RefPersonId == p2Id &&
c.RelationshipId == rId &&
x.Approved &&
x.Checked &&
x.Hidden == false
select c).Count();
return count > 0;