Skip to content

Commit

Permalink
修复newexpression在表达式内解析值不生效的bug,发布x.6.0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Aug 13, 2022
1 parent 34c3844 commit 7273daa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions nuget-publish.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:start
::定义版本
set EFCORE2=2.6.0.27
set EFCORE3=3.6.0.27
set EFCORE5=5.6.0.27
set EFCORE6=6.6.0.27
set EFCORE2=2.6.0.28
set EFCORE3=3.6.0.28
set EFCORE5=5.6.0.28
set EFCORE6=6.6.0.28

::删除所有bin与obj下的文件
@echo off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ private ShardingPredicateResult IsShardingWrapConstant(MethodCallExpression meth
/// <param name="expression"></param>
/// <returns></returns>
private bool ExpressionCanGetValue(Expression expression)
{
{
return expression is ConstantExpression
|| expression is NewExpression
|| expression is ListInitExpression
|| expression is NewArrayExpression
|| (expression is MemberExpression member && (member.Expression is ConstantExpression ||
member.Expression is MemberExpression ||
member.Expression is MemberExpression))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ protected object GetExpressionValue(Expression expression)
{
case ConstantExpression e:
return e.Value;
case NewExpression e:
return e.Constructor?.Invoke(e.Arguments.Select(a => ((ConstantExpression)a).Value).ToArray());

case MemberExpression e when e.Member is FieldInfo field:
return field.GetValue(
Expand Down
1 change: 1 addition & 0 deletions test/ShardingCore.CommonTest/ShardingTableTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void TestSingleTable()
var obj1 = new {time=new DateTime(2022, 1, 2)};
var queryables=new List<IQueryable<TestTimeEntity>>()
{
new List<TestTimeEntity>().AsQueryable().Where(o=>o.Time== new DateTime(2022, 1, 2)),
new List<TestTimeEntity>().AsQueryable().CheckBetween((DateTime?)queryTime,(DateTime?)queryTime3,o=>o.Time),
new List<TestTimeEntity>().AsQueryable().Where(o=>o.Time==times2[0]),
new List<TestTimeEntity>().AsQueryable().Where(o=>o.Time>=times2[0]&&o.Time<times2[1]),
Expand Down

0 comments on commit 7273daa

Please sign in to comment.