From efdd8cbaf0a8d1b9aa4ad80b5d0fe3e3f36f6fa7 Mon Sep 17 00:00:00 2001 From: Alex Yakunin Date: Thu, 14 Sep 2023 06:27:06 -0700 Subject: [PATCH] chore: minor changes in DbEntityResolver.cs --- src/Stl.Fusion.EntityFramework/DbEntityResolver.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Stl.Fusion.EntityFramework/DbEntityResolver.cs b/src/Stl.Fusion.EntityFramework/DbEntityResolver.cs index c669c45a9..1c298e93f 100644 --- a/src/Stl.Fusion.EntityFramework/DbEntityResolver.cs +++ b/src/Stl.Fusion.EntityFramework/DbEntityResolver.cs @@ -42,7 +42,7 @@ public record Options public Expression>? KeyExtractor { get; init; } public Expression, IQueryable>>? QueryTransformer { get; init; } public Action> PostProcessor { get; init; } = _ => { }; - public int BatchSize { get; init; } = 8; + public int BatchSize { get; init; } = 14; // Max. EF.CompileQuery parameter count = 15 public Action>? ConfigureBatchProcessor { get; init; } public TimeSpan? Timeout { get; init; } = TimeSpan.FromSeconds(1); public IRetryDelayer RetryDelayer { get; init; } = new RetryDelayer() { @@ -54,7 +54,7 @@ public record Options // ReSharper disable once StaticMemberInGenericType protected static MethodInfo DbContextSetMethod { get; } = typeof(DbContext) .GetMethods(BindingFlags.Public | BindingFlags.Instance) - .Single(m => m.Name == nameof(DbContext.Set) && m.IsGenericMethod && m.GetParameters().Length == 0) + .Single(m => Equals(m.Name, nameof(DbContext.Set)) && m.IsGenericMethod && m.GetParameters().Length == 0) .MakeGenericMethod(typeof(TDbEntity)); protected static MethodInfo QueryableWhereMethod { get; } = new Func, Expression>, IQueryable>(Queryable.Where).Method; @@ -155,12 +155,14 @@ protected Func> CreateCompiledQu lambdaParameters[0] = pDbContext; pKeys.CopyTo(lambdaParameters, 1); var lambda = Expression.Lambda(eBody, lambdaParameters); +#pragma warning disable EF1001 var query = new CompiledAsyncEnumerableQuery(lambda); +#pragma warning restore EF1001 // Locating query.Execute methods var mExecute = query.GetType() .GetMethods() - .SingleOrDefault(m => m.Name == nameof(query.Execute) + .SingleOrDefault(m => Equals(m.Name, nameof(query.Execute)) && m.IsGenericMethod && m.GetGenericArguments().Length == batchSize) ?.MakeGenericMethod(pKeys.Select(p => p.Type).ToArray());