Update gbase

This commit is contained in:
sunkaixuan 2024-11-28 18:48:05 +08:00
parent 49b87e9a6d
commit 4008454ca4

View File

@ -218,9 +218,10 @@ namespace SqlSugar.GBase
GbsCommand sqlCommand = ((GbsConnection)this.Connection).CreateCommand();
if (parameters != null)
{
var bigObjectParams = parameters.Where(o => sql.Contains(o.ParameterName) &&UtilMethods.HasBigObjectParam(o)).ToList<SugarParameter>();
foreach (var param in bigObjectParams)
foreach (var param in parameters.OrderByDescending(it => it.ParameterName.Length))
{
if ((sql.Contains(param.ParameterName) && UtilMethods.HasBigObjectParam(param)) ||
this.CommandType == CommandType.StoredProcedure)
{
// for big object data, in the insert or update statements
// the charactor after the @ParameterName could only be , or ) or space.
@ -233,7 +234,10 @@ namespace SqlSugar.GBase
var gbsParam = sqlCommand.CreateParameter();
gbsParam.DbType = param.DbType;
gbsParam.ParameterName = param.ParameterName;
gbsParam.Direction = param.Direction;
if (UtilMethods.HasBigObjectParam(param))
{
// assign GbsType.
switch (param.TypeName)
{
@ -255,14 +259,19 @@ namespace SqlSugar.GBase
gbsParam.Value = (param.Value == null) ? DBNull.Value : param.Value;
break;
}
}
else
{
gbsParam.Value = (param.Value == null) ? DBNull.Value : param.Value;
}
sqlCommand.Parameters.Add(gbsParam);
if (gbsParam.Direction.IsIn(ParameterDirection.Output, ParameterDirection.InputOutput, ParameterDirection.ReturnValue))
{
if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>();
this.OutputParameters.RemoveAll(it => it.ParameterName == gbsParam.ParameterName);
this.OutputParameters.Add(gbsParam);
}
foreach (var param in parameters.OrderByDescending(it => it.ParameterName.Length))
{
if (sql.Contains(param.ParameterName) && UtilMethods.HasBigObjectParam(param))
{
continue;
}
else
{