I have a linq query that is creating a list. I only want to use the second where clause if affiliationID != 0. Any tips?
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);
Compare
affiliationIdwith 0, if it does not have a value thewherewill always evaluate totrueand the second comparison will not be made: