this is the code i'm using (which is similar to the one in the original thread)
public static IEnumerable<TEntity> InRange<TEntity, TValue>(this IQueryable<TEntity> source, Expression<Func<TEntity, TValue>> selector, int blockSize, IEnumerable<TValue> values)
{
MethodInfo method = null;
foreach (MethodInfo methodInfo in typeof(Enumerable).GetMethods(BindingFlags.Public | BindingFlags.Static))
{
if (methodInfo.Name == "Contains" && methodInfo.IsGenericMethodDefinition && methodInfo.GetParameters().Length == 2)
{
method = methodInfo.MakeGenericMethod(typeof(TValue));
break;
}
}
if (method == null)
throw new InvalidOperationException("Unable to locate Contains");
foreach (TValue[] block in values.GetBlocks(blockSize))
{
var keys = System.Linq.Expressions.Expression.Constant(block, typeof(TValue[]));
var predicate = System.Linq.Expressions.Expression.Call(method, keys, selector.Body);
var lambda = System.Linq.Expressions.Expression.Lambda<Func<TEntity, bool>>(predicate, selector.Parameters[0]);
foreach (TEntity record in source.Where(lambda))
yield return record;
}
}
private static IEnumerable<TValue[]> GetBlocks<TValue>(this IEnumerable<TValue> source, int blockSize)
{
List<TValue> list = new List<TValue>(blockSize);
foreach (TValue item in source)
{
list.Add(item);
if (list.Count == blockSize)
{
yield return list.ToArray();
list.Clear();
}
}
if (list.Count > 0)
yield return list.ToArray();
}
and again, with the notion that:
DataSource2<SomeEntity> data;
List<long> ids;
I call it like so:
ExecuteAsync(new LinqMetaData(adapter).data
.InRange(x => x.Id, 1000, ids)
.AsQueryable());
The execute throws a "source isn't implementing ILLBLGenProQuery. Can't execute the query"