Update Core

This commit is contained in:
sunkaixuan
2022-05-27 11:01:09 +08:00
parent c9e2f900dc
commit 20301b6c6e
5 changed files with 27 additions and 2 deletions

View File

@@ -170,7 +170,15 @@ namespace SqlSugar
+ Context.ParameterIndex;
if (value.ObjToString() != "NULL" && !parameter.ValueIsNull)
{
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
EntityColumnInfo columnInfo = GetColumnInfo(oppoSiteExpression);
if (columnInfo != null && columnInfo.SqlParameterDbType != null&& columnInfo.SqlParameterDbType is System.Data.DbType)
{
this.Context.Parameters.Add(new SugarParameter(appendValue, value, (System.Data.DbType)columnInfo.SqlParameterDbType));
}
else
{
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
}
}
else
{
@@ -251,6 +259,19 @@ namespace SqlSugar
}
}
}
private EntityColumnInfo GetColumnInfo(Expression oppoSiteExpression)
{
var oppsite = (oppoSiteExpression as MemberExpression);
if (oppsite == null) return null;
if (this.Context.SugarContext == null) return null;
if (this.Context.SugarContext.Context == null) return null;
if (oppsite.Expression == null) return null;
var columnInfo = this.Context.SugarContext.Context.EntityMaintenance
.GetEntityInfo(oppsite.Expression.Type).Columns.FirstOrDefault(it => it.PropertyName == oppsite.Member.Name);
return columnInfo;
}
protected void AppendOpreator(ExpressionParameter parameter, bool? isLeft)
{
if (isLeft == true)