diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs index 4715346b4..3b671adc4 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs @@ -162,12 +162,12 @@ namespace SqlSugar { this.DbType = System.Data.DbType.UInt16; } - else if (type.Name == "TimeOnly") + else if (type?.Name == "TimeOnly") { this.DbType = System.Data.DbType.Time; this.Value = UtilMethods.TimeOnlyToTimeSpan(this.Value); } - else if (type.Name == "DateOnly") + else if (type?.Name == "DateOnly") { this.DbType = System.Data.DbType.Date; this.Value = UtilMethods.DateOnlyToDateTime(this.Value); diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs index 4715346b4..3b671adc4 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs @@ -162,12 +162,12 @@ namespace SqlSugar { this.DbType = System.Data.DbType.UInt16; } - else if (type.Name == "TimeOnly") + else if (type?.Name == "TimeOnly") { this.DbType = System.Data.DbType.Time; this.Value = UtilMethods.TimeOnlyToTimeSpan(this.Value); } - else if (type.Name == "DateOnly") + else if (type?.Name == "DateOnly") { this.DbType = System.Data.DbType.Date; this.Value = UtilMethods.DateOnlyToDateTime(this.Value);