Merge branch 'main' of github.com:dotnetcore/sharding-core

This commit is contained in:
xuejiaming 2022-06-20 22:37:36 +08:00
commit 36c5544608
1 changed files with 19 additions and 6 deletions

View File

@ -53,11 +53,20 @@ namespace ShardingCore.Core.Internal.Visitors
);
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")
);
{
if (e.Expression == null&&property.DeclaringType==typeof(DateTime)&&property.Name==nameof(DateTime.Now))
{
return DateTime.Now;
}
else
{
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:
{
@ -87,14 +96,18 @@ namespace ShardingCore.Core.Internal.Visitors
case MethodCallExpression e:
{
var expressionValue = GetExpressionValue(e.Object);
return e.Method.Invoke(
GetExpressionValue(e.Object),
expressionValue,
e.Arguments
.Select(
a => GetExpressionValue(a)
)
.ToArray()
);
}
case UnaryExpression e when e.NodeType == ExpressionType.Convert:
{
return GetExpressionValue(e.Operand);