当leaId
和seaId
大于零时,以下方法会返回数据。如果值大于零,则LINQ包含“&&”运算符
如果只输入leaId
,我应该如何更改查询以返回数据?
由于&&
运营商没有返回,因为seaId
是可选的并且等于零。
public IQueryable<Stand> GetStand(int leaId, int seaId = 0)
{
return from c in db.Stands where c.LeaID == leaId && c.SeaID == seaId
select new Stand
{
//something
}
}
'如果(seaId == 0)从C在db.Stands回报,其中c.LEadID == leadId其他<您的当前查询>' –