c# - Apply multiple expression in linq -
having different kind of filter following used in different situation. how apply more 1 filter in linq.
expression<func<data, bool>> filter = bt => bt.condition1 == condition1; expression<func<data, bool>> filter2 = bt => bt.condition2 == condition2; expression<func<data, bool>> filter3 = bt => bt.condition3 == condition3; var result = datalist.where(filter1); var result2 = datalist.where(filter2, filter3); //syntax error var result3 = datalist.where(filter2).where(filter3); //is proper? var result4 = datalist.where(filter2 || filter3); //syntax error
you can call .where(filter)
every filter want apply.
you can filter ienumerable<t>
.where()
returns again, filtering out elements want.
usage:
ienumerable<sometype> result = datalist.where(filter1).where(filter2).where(filter3);
what aswell have filtering conditions in single expression, instead of multiple ones.
Comments
Post a Comment