我有一个正在创建列表的 linq 查询。我只想使用第二个where
子句 if affiliationID != 0
。有小费吗?
var associations = (from a in ftjent.Associations
join ap in ftjent.AssociationProducts on a.AssociationID equals ap.AssociationID
where ap.Product.Name == productName
where a.AffiliationID == affiliationID
select new
{
a.Acronym,
a.AssociationID,
a.Name
}
).Distinct().OrderBy(assoc => assoc.Acronym);