From afec836c52a34cef47d095c4ce95e242aeabf23d Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Wed, 14 Sep 2022 16:44:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/Sample.MySql/Sample.MySql.csproj | 6 ++--- .../DbContextReplaceQueryableVisitor.cs | 24 ++----------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/samples/Sample.MySql/Sample.MySql.csproj b/samples/Sample.MySql/Sample.MySql.csproj index fb86cb18..08b63cb5 100644 --- a/samples/Sample.MySql/Sample.MySql.csproj +++ b/samples/Sample.MySql/Sample.MySql.csproj @@ -7,15 +7,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs index 2294cf2f..6095b64b 100644 --- a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs +++ b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor.cs @@ -102,10 +102,10 @@ namespace ShardingCore.Core.Internal.Visitors if (RootIsVisit&&node.Method.ReturnType.IsMethodReturnTypeQueryableType()&&node.Method.ReturnType.IsGenericType) { #if EFCORE2 || EFCORE3 - var notRoot = node.Arguments.All(o => !(o is ConstantExpression constantExpression&&constantExpression.Value is IQueryable)); + var notRoot = node.Arguments.IsEmpty(); #endif #if !EFCORE2 && !EFCORE3 - var notRoot = node.Arguments.All(o => !(o is QueryRootExpression)); + var notRoot = node.Arguments.IsEmpty(); #endif if (notRoot) { @@ -131,12 +131,6 @@ namespace ShardingCore.Core.Internal.Visitors return whereCallExpression; } - public Expression> WhereTrueExpression() - { - return t => true; - } - - internal sealed class TempVariable { public IQueryable Queryable { get; } @@ -151,20 +145,6 @@ namespace ShardingCore.Core.Internal.Visitors return Queryable; } } - internal sealed class TempMethodVariable - { - public IQueryable Queryable { get; } - - public TempMethodVariable(Func> func) - { - Queryable = func(); - } - - public IQueryable GetQueryable() - { - return Queryable; - } - } internal sealed class TempDbVariable {