From dcced0a7b874a0866832296d4bd9407ea7c1ee12 Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Fri, 1 Sep 2023 08:30:54 +0800 Subject: [PATCH] =?UTF-8?q?[#251]=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E5=80=BC=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/WeatherForecastController.cs | 10 +++++++++- .../Sharding/Visitors/ShardingExpressionVisitor.cs | 2 +- test/ShardingCore.CommonTest/ShardingTableTime.cs | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/samples/Sample.MySql/Controllers/WeatherForecastController.cs b/samples/Sample.MySql/Controllers/WeatherForecastController.cs index f2583440..2b0e7247 100644 --- a/samples/Sample.MySql/Controllers/WeatherForecastController.cs +++ b/samples/Sample.MySql/Controllers/WeatherForecastController.cs @@ -194,7 +194,15 @@ namespace Sample.MySql.Controllers name = o.Key.Name, count = o.Count() }).ToListAsync(); - var x=await (from ut in _defaultTableDbContext.Set() + + var asyncEnumerator = _defaultTableDbContext.Set().AsAsyncEnumerable(); + await foreach (var sysTest in asyncEnumerator) + { + await Task.Delay(1000); + Console.WriteLine("1"); + } + + var x=await (from ut in _defaultTableDbContext.Set() from uu in _defaultTableDbContext.Set() where ut.Id == uu.Id select ut).FirstOrDefaultAsync(); diff --git a/src/ShardingCore/Sharding/Visitors/ShardingExpressionVisitor.cs b/src/ShardingCore/Sharding/Visitors/ShardingExpressionVisitor.cs index 46b422a5..d7b68572 100644 --- a/src/ShardingCore/Sharding/Visitors/ShardingExpressionVisitor.cs +++ b/src/ShardingCore/Sharding/Visitors/ShardingExpressionVisitor.cs @@ -45,7 +45,7 @@ namespace ShardingCore.Core.Internal.Visitors case ConstantExpression e: return e.Value; case NewExpression e: - return e.Constructor?.Invoke(e.Arguments.Select(a => ((ConstantExpression)a).Value).ToArray()); + return e.Constructor?.Invoke(e.Arguments.Select(GetExpressionValue).ToArray()); case MemberExpression e when e.Member is FieldInfo field: return field.GetValue( diff --git a/test/ShardingCore.CommonTest/ShardingTableTime.cs b/test/ShardingCore.CommonTest/ShardingTableTime.cs index 5ad4e183..f4f7d19c 100644 --- a/test/ShardingCore.CommonTest/ShardingTableTime.cs +++ b/test/ShardingCore.CommonTest/ShardingTableTime.cs @@ -95,8 +95,10 @@ namespace ShardingCore.CommonTest var times2 = new []{queryTime,queryTime2}; var obj1 = new {time=new DateTime(2022, 1, 2)}; var dateTime = (DateTime?)new DateTime(2022, 1, 2); + var day = 2; var queryables=new List>() { + new List().AsQueryable().Where(o=>o.Time== new DateTime(2022, 1, day)), new List().AsQueryable().Where(o=>o.Time== dateTime), new List().AsQueryable().Where(o=>dateTime==o.Time ), new List().AsQueryable().Where(o=>o.Time== new DateTime(2022, 1, 2)),