I wonder if you can do something like this:
public List<T> FindOrder<T>(Expression<Func<T, bool>> predicate) where T : class
{
DbSet<Preventivos> preventivos = this.Preventivos;
return (from p in preventivos
where predicate
select new...
Not like that, no - but you can write:
return preventivos.Where(predicate).Select(...);
... although your code example seems to be unclear as to whether this is really generic or whether it only deals with Preventivos
.
The point is that the query expression you've provided would add an extra "wrapper" layer:
return preventivos.Where(p => predicate)
.Select(p => new { ... });
... whereas you want to pass the predicate expression tree directly to the Where
call.
See more on this question at Stackoverflow