I have table Requests, that has Approvals :
public class Request {
public virtual List<Approval> Approvals { get; set; }
}
Requests come from DB
public DbSet<Request> Request { get; set; }
I have extension method:
public static IQueryable<Request> HaveApprovals(this IQueryable<Request> requests) {
return requests.Where(r => r.ActiveApprovals().Count() > 0).ToList();
}
And another extension method:
public static IEnumerable<Approval> ActiveApprovals(this Request request) {
return request.Approvals.Where(a => !a.Deleted);
}
But getting error:
LINQ to Entities does not recognize the method 'System.Collections.Generic.IEnumerable`1[Domain.Approval] ActiveApprovals(Domain.Request)' method, and this method cannot be translated into a store expression.
For some reason one extension method is able to be translated to LINQ, but when using extension method inside another, then it fails to translate. Any suggestions?