У меня есть много расширенных «фильтров», таких как этот:
public static IQueryable<Customer> ByCustomerID(this IQueryable<Customer> qry, int customerID)
{
return from c in qry
where c.CustomerID == customerID
select c;
}
To GetCustomers () (IQueryable), например .ByCompanyID () и т. Д., И я хотел бы добавить эти фильтрыв зависимости от критериев.
Вроде как:
var result = _rep.GetCustomers();
if(useByCompanyID)
// add .ByCompanyID(companyID) to "result"
if(useByCountry)
// add .ByCountry(country) to "result"
// etc etc....
//do something with "result"
это возможно сделать с помощью каркаса сущностей и linq?
/ M