Browse Source

Update custom type

pull/31/head
sunkaixuan 2 years ago
parent
commit
5d969e5368
  1. 2
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs
  2. 2
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs
  3. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/ConstantExpressionResolve.cs

2
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -304,7 +304,7 @@ namespace SqlSugar
GetDbColumnIndex++;
return pname;
}
else if (columnInfo.PropertyType.Name == "TimeOnly" && name != null && !name.ObjToString().StartsWith(Builder.SqlParameterKeyWord))
else if (columnInfo.PropertyType!=null&&columnInfo.PropertyType.Name == "TimeOnly" && name != null && !name.ObjToString().StartsWith(Builder.SqlParameterKeyWord))
{
var timeSpan = UtilMethods.TimeOnlyToTimeSpan(columnInfo.Value);
var pname = Builder.SqlParameterKeyWord + columnInfo.DbColumnName + "_ts" + GetDbColumnIndex;

2
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs

@ -412,7 +412,7 @@ namespace SqlSugar
this.Parameters.Add(p);
return p.ParameterName;
}
else if (columnInfo.PropertyType.Name == "TimeOnly" && name != null && !name.ObjToString().StartsWith(Builder.SqlParameterKeyWord))
else if (columnInfo.PropertyType!=null&&columnInfo.PropertyType.Name == "TimeOnly" && name != null && !name.ObjToString().StartsWith(Builder.SqlParameterKeyWord))
{
var timeSpan = UtilMethods.TimeOnlyToTimeSpan(columnInfo.Value);
var pname = Builder.SqlParameterKeyWord + columnInfo.DbColumnName + "_ts" + GetDbColumnIndex;

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/ConstantExpressionResolve.cs

@ -46,7 +46,7 @@ namespace SqlSugar
{
var member = (exp as MemberExpression);
var memberParent = member.Expression;
if (memberParent != null)
if (memberParent != null&& this.Context?.SugarContext?.Context!=null)
{
var entity = this.Context.SugarContext.Context.EntityMaintenance.GetEntityInfo(memberParent.Type);
var columnInfo = entity.Columns.FirstOrDefault(it => it.PropertyName == member.Member.Name);

Loading…
Cancel
Save