如何将字符串转换为linq where子句

时间:2014-10-20 09:10:25

标签: c# .net linq entity-framework-5

在我的项目中,我有一个高级过滤功能,用户可以保存此过滤器
现在在我的过滤器中我有FilterQuery,我在其中保存过滤器 喜欢

   City =NewDelhi,Faridabad,Noida,Gurgaon,GreaterNoida 
   && ServiceType=1,2 
   && NetPriceMax=1000
   && CaseStatus=1,2
   && NetPriceMax=1000 
   && CreatedDate>=20/10/2014 
   && CreatedDate<=20/10/2014 
   && AppointmentDate>=17/10/2014 
   && AppointmentDate<=20/10/2014

现在在Linq查询中,它就像

一样
               from cs in UnitOfWork.CaseRepository.All()
                    .Where(cs => cs.City = NewDelhi)

如何将这些字符串转换为Linq查询?

1 个答案:

答案 0 :(得分:0)

来自UnitOfWork.CaseRepository.All()中的cs 。在哪里(cs =&gt; cs.City ==&#34; NewDelhi&#34; || cs.City ==&#34; Faridabad&#34; || cs.City ==&#34; Noida&#34; || cs.City ==&#34; Gurgaon&#34; || cs.City ==&#34; GreaterNoida&#34;) .Where(s =&gt; s.ServiceType == 1 || s.ServiceType == 2) 。哪里(p =&gt; p.NetPriceMax == 1000)

......等等

相关问题