diff --git a/nuget-publish.bat b/nuget-publish.bat index 15219ef2..c920ad76 100644 --- a/nuget-publish.bat +++ b/nuget-publish.bat @@ -1,6 +1,6 @@ :start ::定义版本 -set SHARDINGCORE7=7.0.0.4 +set SHARDINGCORE7=7.0.0.5 set SHARDINGCORE2_6=6.8.0.9 ::删除所有bin与obj下的文件 diff --git a/samples/Sample.SqlServer/Controllers/ValuesController.cs b/samples/Sample.SqlServer/Controllers/ValuesController.cs index b0d4306d..5deeb5d4 100644 --- a/samples/Sample.SqlServer/Controllers/ValuesController.cs +++ b/samples/Sample.SqlServer/Controllers/ValuesController.cs @@ -405,6 +405,16 @@ namespace Sample.SqlServer.Controllers s => s.SetProperty(b => b.Age, b => b.Age + 1)); + return Ok(); + } + [HttpGet] + public async Task Get9() + + { + + var resultx112331tt2 = await _defaultTableDbContext.Set().FromSqlRaw("select *from systest where id='3'").FirstOrDefaultAsync(); + + return Ok(); } diff --git a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor7.cs b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor7.cs index 514818dd..11f45ab5 100644 --- a/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor7.cs +++ b/src/ShardingCore/Sharding/Visitors/DbContextReplaceQueryableVisitor7.cs @@ -6,6 +6,7 @@ using System.Reflection; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.Query.Internal; using ShardingCore.Core.Internal.Visitors; using ShardingCore.Exceptions; using ShardingCore.Extensions; @@ -156,11 +157,23 @@ namespace ShardingCore.Core.Internal.Visitors var newQueryable = targetIQ.Provider.CreateQuery(targetIQ.Expression); if (Source == null) Source = newQueryable; - //如何替换ef5的set - var replaceQueryRoot = new ReplaceSingleQueryRootExpressionVisitor(); - replaceQueryRoot.Visit(newQueryable.Expression); RootIsVisit = true; - return base.VisitExtension(replaceQueryRoot.QueryRootExpression); + + if (queryRootExpression is FromSqlQueryRootExpression fromSqlQueryRootExpression) + { + var sqlQueryRootExpression = new FromSqlQueryRootExpression(newQueryable.Provider as IAsyncQueryProvider, + fromSqlQueryRootExpression.EntityType, fromSqlQueryRootExpression.Sql, + fromSqlQueryRootExpression.Argument); + + return base.VisitExtension(sqlQueryRootExpression); + } + else + { + //如何替换ef5的set + var replaceQueryRoot = new ReplaceSingleQueryRootExpressionVisitor(); + replaceQueryRoot.Visit(newQueryable.Expression); + return base.VisitExtension(replaceQueryRoot.QueryRootExpression); + } } return base.VisitExtension(node); diff --git a/src/ShardingCore/ShardingCore.csproj b/src/ShardingCore/ShardingCore.csproj index 6b3e00ea..efc758ab 100644 --- a/src/ShardingCore/ShardingCore.csproj +++ b/src/ShardingCore/ShardingCore.csproj @@ -1,7 +1,7 @@  net6;net7; - 7.0.0.4 + 7.0.0.5 true TRACE;DEBUG;SHARDINGCORE7; latest