我有这个ActionResult:
[HttpPost]
public ActionResult ProcessesFilter( ProcessesFilterViewModel model)
{
IQueryable<Process> results = db.Processes
.Include(s => s.Customers)
if (model.Case>0)
{
result = result.Where(s => s.Case == model.Case);
}
if (model.CustomerID != null)
{
results = results
.Where(s => s.Customers.CustomerID == model.CustomerID);<==== Doesnt Work
}
model.results = results.ToList();
return View(model);
}
.Where(s =&gt; s.Customers.CustomerID == model.CustomerID);&lt; ====不起作用
它怎么能起作用?
答案 0 :(得分:1)
您需要使用Any
。例如:
if (model.CustomerID != null)
{
results = results
.Where(s => s.Customers.Any(c => c.CustomerID == model.CustomerID));
}