efcore7的fromsqlraw的bug
This commit is contained in:
xuejiaming 2022-11-18 09:55:13 +08:00
parent 7bab73c6e1
commit ce1faf8d54
4 changed files with 29 additions and 6 deletions

View File

@ -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下的文件

View File

@ -405,6 +405,16 @@ namespace Sample.SqlServer.Controllers
s => s.SetProperty(b => b.Age, b => b.Age + 1));
return Ok();
}
[HttpGet]
public async Task<IActionResult> Get9()
{
var resultx112331tt2 = await _defaultTableDbContext.Set<SysTest>().FromSqlRaw("select *from systest where id='3'").FirstOrDefaultAsync();
return Ok();
}

View File

@ -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,12 +157,24 @@ namespace ShardingCore.Core.Internal.Visitors
var newQueryable = targetIQ.Provider.CreateQuery(targetIQ.Expression);
if (Source == null)
Source = newQueryable;
RootIsVisit = true;
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);
RootIsVisit = true;
return base.VisitExtension(replaceQueryRoot.QueryRootExpression);
}
}
return base.VisitExtension(node);
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7;</TargetFrameworks>
<Version>7.0.0.4</Version>
<Version>7.0.0.5</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;SHARDINGCORE7;</DefineConstants>
<LangVersion>latest</LangVersion>