diff --git a/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs b/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs index 24bb0d275..a2a3df84b 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/2_Update.cs @@ -113,6 +113,8 @@ namespace OrmTest.Demo var t23= db.Updateable(new Student() { }) .Where(p => p.SchoolId == SqlFunc.Subqueryable().Where(s => s.SchoolId == p.Id).Select(s => s.Id)).ExecuteCommand(); + + var t24 = db.Updateable(new Student() { }).WhereColumns(it=>it.CreateTime).ExecuteCommand(); } } } diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index 347a0b8ab..cd1826449 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -17,6 +17,7 @@ namespace SqlSugar public UpdateBuilder UpdateBuilder { get; set; } public IAdo Ado { get { return Context.Ado; } } public T[] UpdateObjs { get; set; } + public bool UpdateParameterIsNull { get; set; } public bool IsMappingTable { get { return this.Context.MappingTables != null && this.Context.MappingTables.Any(); } } public bool IsMappingColumns { get { return this.Context.MappingColumns != null && this.Context.MappingColumns.Any(); } } public bool IsSingle { get { return this.UpdateObjs.Length == 1; } } @@ -152,6 +153,7 @@ namespace SqlSugar public IUpdateable WhereColumns(Expression> columns) { + Check.Exception(UpdateParameterIsNull==true, "Updateable().Updateable is error,Use Updateable(obj).WhereColumns"); var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); if (this.WhereColumnList == null) this.WhereColumnList = new List(); foreach (var item in whereColumns) diff --git a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs index fa2705e39..72efe9a52 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs @@ -10,6 +10,8 @@ namespace SqlSugar public interface IUpdateable where T : class, new() { UpdateBuilder UpdateBuilder { get; set; } + bool UpdateParameterIsNull { get; set; } + int ExecuteCommand(); bool ExecuteCommandHasChange(); Task ExecuteCommandAsync(); diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 7fd4259bc..203da40e3 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -532,7 +532,9 @@ namespace SqlSugar } public virtual IUpdateable Updateable() where T : class, new() { - return this.Context.Updateable(new T[] { new T() }); + var result= this.Context.Updateable(new T[] { new T() }); + result.UpdateParameterIsNull=true; + return result; } public virtual IUpdateable Updateable(Dictionary columnDictionary) where T : class, new() {