Jon Skeet has a good answer (LINQ Between Operator) about how to write an expression tree which will run in LINQ to SQL to perform a between operation. Ive tried this with EF but it fails due to the Invoke call below being unsupported.
public static Expression<Func<TSource, bool>> Between<TSource, TKey>(Expression<Func<TSource, TKey>> keySelector, TKey low, TKey high) where TKey : IComparable<TKey>
{
Expression key = Expression.Invoke(keySelector, keySelector.Parameters.ToArray());
The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.
Is there an alternative to Invoke which can be used here to get the property specified by the input lambda so this works with EF?