我在MVC3应用程序中有一个简单的实体框架查询,就像这样
var instances= db.Instances.Include(c => c.CompanyLead).Include(c => c.SalesLead).Include(c => c.Customer);
return View(instances);
此查询工作正常,基本上返回所有实例。但是,我需要过滤此查询并基本上添加短语:
var instances = db.Instances.Include(c =&gt; c.CompanyLead).Include(c =&gt; c.SalesLead).Include(c =&gt; c.Customer) WHERE InstanceType = x < /强>
我不想恢复到带有DB Context对象的ObjectQuery类。我以为我可以改变这个查询。我错了吗?
答案 0 :(得分:0)
var instances = db.Instances.Where(c =&gt; c.InstanceType == “x”)。包括(c =&gt; c.CompanyLead).Include(c =&gt; c.SalesLead).Include(c =&GT; c.Customer)