If condition in LINQ Where clause

Hasan picture Hasan · Sep 10, 2010 · Viewed 89.2k times · Source

Can I use if clause with Linq where?

Answer

logical8 picture logical8 · Jun 19, 2014
var query = someList.Where(a => (someCondition)? a == "something" : true);

so, if 'someCondition' is false, 'Where' will be skipped.