diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 8db1f1de1..903cf27b7 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -432,7 +432,7 @@ namespace SqlSugar { FieldName = item, ConditionalType = ConditionalType.Equal, - FieldValue = model[item].ObjToString(), + FieldValue = model[item]==null?"null" : model[item].ObjToString(), CSharpTypeName = model[item] == null ? null : model[item].GetType().Name })); i++; diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs index 5a3fcf213..38afa76d9 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs @@ -164,8 +164,19 @@ namespace SqlSugar switch (item.ConditionalType) { case ConditionalType.Equal: - builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "=", parameterName); - parameters.Add(new SugarParameter(parameterName, GetFieldValue(item))); + if (item.FieldValue!=null&&item.FieldValue == "null"&&item.FieldValue!= "[null]") + { + builder.AppendFormat($" {item.FieldName.ToSqlFilter()} is null "); + } + else + { + if (item.FieldValue == "[null]") + { + item.FieldValue = "null"; + } + builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "=", parameterName); + parameters.Add(new SugarParameter(parameterName, GetFieldValue(item))); + } break; case ConditionalType.Like: builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "LIKE", parameterName);