diff --git a/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs b/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs index 9874c3521..7fb7a5251 100644 --- a/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs +++ b/Src/Asp.Net/SqlServerTest/BugTest/Bug2.cs @@ -93,7 +93,8 @@ namespace OrmTest.BugTest BrandId = -1, UserLevel = 1 }).IgnoreColumns(m => new { m.CreditUpdatetime,m.UserId }).ToSql(); - + DB.CodeFirst.InitTables(typeof(DataTest)); + DB.Insertable(new DataTest()).ExecuteCommand(); } } @@ -168,5 +169,10 @@ namespace OrmTest.BugTest public DateTime CreditUpdatetime { get; set; } #endregion } + + public class DataTest { + [SugarColumn( ColumnDataType = "time",IsNullable =true)] + public TimeSpan? dateTime { get; set; } + } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs index f6dbbf4b3..1a8f95e66 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs @@ -97,7 +97,8 @@ namespace SqlSugar } else if (type == UtilConstants.TimeSpanType) { - this.Value = this.Value.ToString(); + if (this.Value != null) + this.Value = this.Value.ToString(); } }