first time I've not managed to find an existing answer to my problem.
Basically I have a generic expression to allow filtering active items on an IQueryable usage:
queryableGoesHere.ActiveAtItems(x => x.StartDate, x => x.EndDate, asAtDate, true)
Implementation of expression:
public static Expression<Func<T, Func<T, DateTime>, Func<T, DateTime?>, DateTime?, bool?, bool>> GetActiveAtItemsExprGeneric<T>()
where T : class
{
return (o, from, to, givenTime, isActive) => (!to(o).HasValue);
}
I've simplified the return line to highlight the problem. It works untill I attempt to use either of the two funcs, in this case 'to(o)'.
It fails when using linqkit here:
return (from m in source.AsExpandable()
where predicate.Invoke(m, arg1, arg2, arg3, arg4)
select m);
With the exception "Additional information: Unable to cast object of type 'System.Linq.Expressions.TypedParameterExpression' to type 'System.Linq.Expressions.LambdaExpression'."
Now I've never passed a func and used it in an expression in this way, and my google-fu has failed to find any reference to this exception. I'm unsure if what I'm doing is even possible... Any help would be much appreciated!