- 优化 GBase 数据库存储过程参数化的执行;#965

This commit is contained in:
2881099 2021-12-17 18:52:55 +08:00
parent 6826dec09f
commit 9bd6e83ed7
2 changed files with 23 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>2.8.100-preview1013</Version> <Version>2.6.100</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>FreeSql;GBase</Authors> <Authors>FreeSql;GBase</Authors>
<Description>FreeSql 数据库实现,基于 南大通用 8.0</Description> <Description>FreeSql 数据库实现,基于 南大通用 8.0</Description>

View File

@ -1,8 +1,10 @@
using FreeSql.GBase.Curd; using FreeSql.GBase.Curd;
using FreeSql.Internal.CommonProvider; using FreeSql.Internal.CommonProvider;
using System; using System;
using System.Data;
using System.Data.Common; using System.Data.Common;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -28,6 +30,26 @@ namespace FreeSql.GBase
this.DbFirst = new GBaseDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.DbFirst = new GBaseDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
this.CodeFirst = new GBaseCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new GBaseCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
this.Aop.CommandBefore += (_, e) =>
{
if (e.Command.CommandType == CommandType.StoredProcedure)
{
if (e.Command.CommandText.Trim().StartsWith("{call ", StringComparison.OrdinalIgnoreCase) == false)
{
var args = string.Join(", ", Enumerable.Range(0, e.Command.Parameters.Count)
.Select(a => "?"));
var cmdText = $"{{call {e.Command.CommandText}({args})}}";
foreach (DbParameter parameter in e.Command.Parameters)
{
if (parameter.DbType == DbType.String && parameter.Size <= 0)
parameter.Size = 255;
}
e.Command.CommandText = cmdText;
}
}
};
this.Aop.AuditDataReader += (_, e) => this.Aop.AuditDataReader += (_, e) =>
{ {
var dbtype = e.DataReader.GetDataTypeName(e.Index); var dbtype = e.DataReader.GetDataTypeName(e.Index);