私のアプリケーションは1.1.1フレームワークを指し示す.netコアです。 )EFコアの左結合でスキップ/取れません。 '縮小可能ノードにする必要があります'というエラーが表示されます
var queryEF = (from b in context.table1
orderby b.column1 descending
select new Table1
{
column1 = b.column1,
});
queryEF = queryEF.Skip(3).Take(10).AsQueryable();
var query2 = (from b in queryEF
join lb in context.table2
on b.column1 equals lb.column1
into tablejoin
from blb in
tablejoin.DefaultIfEmpty()
select new
{
b.column1
});
if (query2 != null)
{
foreach (var locnBranch in query2.AsEnumerable())
{
}
}
上記のクエリが失敗し、AsEnumerable(実行時:私は使用しています DBプロバイダは、次のように私が実行しようとしているクエリがあるPomelo.EntityFrameworkCore.MySql
です。それは 'reduceableノード'エラーをスローします。
例外の詳細:
{System.ArgumentException: must be reducible node
at System.Linq.Expressions.Expression.ReduceAndCheck()
at System.Linq.Expressions.Expression.ReduceExtensions()
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExtensionExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMemberExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteLambdaExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
at System.Linq.Expressions.Expression`1.Compile(Boolean preferInterpretation)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambda[TResults]()
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, ILogger logger, Type contextType)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_0`1.<CompileQuery>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Remotion.Linq.QueryableBase`1.GetEnumerator()
at GetAll() in E:\Test\Repository.cs:line 291
at Get(List`1 Keys, String operatingCompany, Boolean isTrading, Int32 firstRecord, Int32 count, String clientIPAddress, String sortBy, String sortOrder) in E:\Test\Repository.cs:line 51
at Get(List`1 Keys, String operatingCompany, Boolean isTrading, Int32 firstRecord, Int32 count, String clientIPAddress, String sortBy, String sortOrder) in E:\BusinessServices\Service.cs:line 121
at Get(List`1 Keys, String operatingCompany, Boolean isTrading, Int32 firstRecord, Int32 count, String clientIPAddress, String sortBy, String sortOrder) in E:\Controllers\esController.cs:line 54
at lambda_method(Closure , Object , Object[])
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionFilterAsync>d__28.MoveNext()}
上記のクエリは、それから取る/スキップ削除した後、正常に動作します。 私はEF5でクエリをテストしましたが、何の問題もなく、EFコアでしか機能しません。
これは現在のEFコアの多くのバグの1つです。 'queryEF.Skip(3).Take(10).AsQueryable()'を 'queryEF.Skip(3).Take(10).Select(x => x)'に変更すると例外が修正されます(少なくとも1.1.2 )が、SQLクエリではなくメモリで結合が実行されます。 –