I have this list of id's:
string[] ids = { "AF1", "AF2", "AF3" };
and my goal is to intersect the ids of this list with the table below and sum the age in a single linq query without making a foreach:
PersonId |Name |Age
AF1 |John |20
AF2 |Oscar |50
AF3 |Peter |30
AF4 |Abbey |65
AF5 |Adrian |43
AF6 |Barbara |15
i found that by doing:
order.Lines.Select(x => x.PersonId).Intersect(ids);
i get all the id's in the table but didnt found a way to sum the age :/
the output must be 100