Using one Func <T, bool> with Where () and inheritance
I am trying to use one definition Func<T,bool>to process a class and its descendant. This is what I have:
Func<Job, bool> ValidJob =
j => !j.Deleted && !j.OnHold && j.PostDate <= DateTime.Now && j.ExpireDate > DateTime.Now;
public class JobExtended : Job { }
So, considering that the following works:
IQueryable<Job> jobs = ...
jobs.Where(ValidJob);
However, the following:
IQueryable<JobExtended> jobs = ...
jobs.Where(ValidJob);
I wonder if there can be one in this situation Func<T,bool>, and if so, how? I tried to specify type arguments as suggested, but I had no luck.
+3