我想在某种情况下只执行此操作
somelist.Where(x => x.isTest == true && x.status == request.StatusDescription &&
(x.reqdate >= request.ReferenceDateFrom && x.reqdate <= request.ReferenceDateTo))
和这个用于其他条件
somelist.Where(x => x.status == request.StatusDescription
&& (x.reqdate >= request.ReferenceDateFrom && x.reqdate <= request.ReferenceDateTo))
答案 0 :(得分:3)
怎么样?
var somelist=somelist.Where(x => x.status == request.StatusDescription
&& (x.reqdate >= request.ReferenceDateFrom && x.reqdate <= request.ReferenceDateTo))
if(condition==true){
somelist = somelist.Where(x => x.isTest == true)
}