I understand why I'm getting the following error, however I'm not sure how I could go about providing a solution that can get around it.
{System.NotSupportedException: LINQ to Entities does not recognize the method 'Boolean IsStatus(CDAX.DataModel.ProcessStatusEnum)' method, and this method cannot be translated into a store expression.
I don't want to just return IEnumerable as I want to translate the filters to an underlying SQL statement so that I don't query on so many rows etc
public override IQueryable<Session> GetQuery()
{
Func<Session, bool> activeSessions = (session) => !session.IsStatus(ProcessStatusEnum.Deleted);
// these functions are causing issues. I'm not sure how to change them to
// work with IQueryable??
return base.GetQuery().Where(p => activeSessions(p) && _queryFilter.FilterOn(p.Customer));
}
The _queryFilter class is an interface such as:
public interface IDataQueryFilter
{
bool FilterOn(Customer obj);
}
Customer is just an Entity object in my database with properties such as Id, CustomerNumber etc
Session is another Entity object in my database and the IsStatus method is such:
public bool IsStatus(ProcessStatusEnum status)
{
return SessionStatus == (byte)status;
}
The conditions I use are typically very simple so I believe they should be able to translate to SQL. I guess it's just because they are within functions that they cannot. Could I perhaps use something else as the return type to get these to work?