Reputation: 2402
I'm trying to select ID
from an Ilist<T>
where 2 boolean properties are equal true
myList.Select(t => t.IsValid && t.IsBalance).Distinct().ToList();
but if I want to return and select only the t.ID
where t.IsValid
and t.IsBalance
how to do so ? I couldn't find an example
Thank you
Upvotes: 2
Views: 966
Reputation: 37299
Use Where
for the filtering and Select
for projection:
myList.Where(t => t.IsValid && t.IsBalance).Select(t => t.ID).Distinct().ToList();
You can also use query syntax:
var result = (from t in myList
where t.IsValue && t.IsBalance
select t.ID).Distinct().ToList();
Upvotes: 7