添加一些代码优化

This commit is contained in:
xuejiaming 2022-04-19 21:41:27 +08:00
parent fa9316a718
commit 3b256534c4
4 changed files with 7 additions and 47 deletions

View File

@ -62,6 +62,10 @@ namespace ShardingCore.Extensions
public static string ShardingPrint(this Expression expression)
{
if (expression == null)
{
return null;
}
#if !EFCORE2
return expression.Print();
#endif

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using ShardingCore.Exceptions;
using ShardingCore.Extensions;
namespace ShardingCore.Core.Internal.Visitors
{
@ -48,14 +49,14 @@ namespace ShardingCore.Core.Internal.Visitors
return field.GetValue(
GetExpressionValue(
e.Expression
)
) ?? throw new InvalidOperationException($"cant get expression value,{e.Expression.ShardingPrint()} may be null reference")
);
case MemberExpression e when e.Member is PropertyInfo property:
return property.GetValue(
GetExpressionValue(
e.Expression
)
)??throw new InvalidOperationException($"cant get expression value,{e.Expression.ShardingPrint()} may be null reference")
);
case ListInitExpression e when e.NewExpression.Arguments.Count() == 0:

View File

@ -1,27 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>$(EFCORE6)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE6;</DefineConstants>
<LangVersion>9.0</LangVersion>
<RepositoryUrl>https://github.com/xuejmnet/sharding-core</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>bin\Release\ShardingCore.xml</DocumentationFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Core\ExtensionExpressionComparer\" />
</ItemGroup>
</Project>

View File

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>$(EFCORE5)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE5;</DefineConstants>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>bin\Release\ShardingCore.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.13" />
</ItemGroup>
</Project>