c# - Check if collection contains element with specific properties -
i have 2 collections different entities. how create them 1 collection unique info (companyname & productname & certid).
what seek : 1st collection iterate in loop , check if 2nd collection contains element same certid, productname , companyname. not sure if create good.
if element doesn't contains, need add together it.
releases.foreach( r => { if (!ratings.all(x => x.certid == r.certid && x.companynamewhenrated == r.companynameonstore && x.productnamewhenrated == r.productnameonstore)) { ratings.tolist().add(new urating { certid = r.certid, productnamewhenrated = r.productnameonstore, companynamewhenrated = r.companynameonstore, ucert = r.ucert, ragerating = r.ucert.uratings .where(u => u.certid == r.certid && u.productnamewhenrated != r.productnameonstore && u.companynamewhenrated != r.companynameonstore) .select(ur => ur.ragerating).first() }); } });
if (!ratings.all(...))
means ratings have match release, not want. utilize if(!ratings.any(...))
means of ratings has match release.
c# linq equals contains
No comments:
Post a Comment