Open
Description
openedon Aug 28, 2024
Our custom LINQ operator are currently implemented as follows, more or less:
return
source.Provider is EntityQueryProvider
? source.Provider.CreateQuery<TEntity>(
Expression.Call(
instance: null,
method: WithPartitionKeyMethodInfo1.MakeGenericMethod(typeof(TEntity)),
source.Expression,
Expression.Constant(partitionKeyValue, typeof(object))))
: source;
This is a needless use of MakeGenericMethod, which is both less efficient and problematic for NativeAOT. Instead, we can use the following pattern in use in the standard LINQ operators (see dotnet/runtime#79717):
return source.Provider.CreateQuery<TSource>(
Expression.Call(
null,
new Func<IQueryable<TSource>, int, IQueryable<TSource>>(Skip).Method,
source.Expression, Expression.Constant(count)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment