If condition in LINQ Where clause

前端 未结 8 2028
星月不相逢
星月不相逢 2020-12-03 06:56

Can I use if clause with Linq where?

8条回答
  •  误落风尘
    2020-12-03 07:22

    var query = someList.Where(a => (someCondition)? a == "something" : true);
    

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

提交回复
热议问题