Skip to content

Commit

Permalink
修复
Browse files Browse the repository at this point in the history
efcore7的fromsqlraw的bug
  • Loading branch information
xuejmnet committed Nov 18, 2022
1 parent 7bab73c commit ce1faf8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nuget-publish.bat
Original file line number Diff line number Diff line change
@@ -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下的文件
Expand Down
10 changes: 10 additions & 0 deletions samples/Sample.SqlServer/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@ public async Task<IActionResult> Get8()
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -156,11 +157,23 @@ protected override Expression VisitExtension(Expression node)
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);
Expand Down
2 changes: 1 addition & 1 deletion src/ShardingCore/ShardingCore.csproj
Original file line number Diff line number Diff line change
@@ -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>
Expand Down

0 comments on commit ce1faf8

Please sign in to comment.