Browse Source

Update Insert time span

pull/30/head
sunkaixuan 2 years ago
parent
commit
1fe20fea04
  1. 9
      Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

9
Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -273,6 +273,7 @@ namespace SqlSugar
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
} }
private int GetDbColumnIndex = 0;
public virtual string GetDbColumn(DbColumnInfo columnInfo ,object name) public virtual string GetDbColumn(DbColumnInfo columnInfo ,object name)
{ {
if (columnInfo.InsertServerTime) if (columnInfo.InsertServerTime)
@ -283,6 +284,14 @@ namespace SqlSugar
{ {
return columnInfo.InsertSql; return columnInfo.InsertSql;
} }
else if (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;
this.Parameters.Add(new SugarParameter(pname, timeSpan));
GetDbColumnIndex++;
return pname;
}
else else
{ {
return name+""; return name+"";

Loading…
Cancel
Save