From 6b760270ae42f8486a7135335433fa65790644b9 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 29 Sep 2022 20:50:32 +0800 Subject: [PATCH] Add UpdateSetColumnsTrue --- Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs | 2 ++ Src/Asp.Net/SqlSugar/SimpleClient.cs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs b/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs index bd58d5b83..63644d147 100644 --- a/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs +++ b/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs @@ -49,6 +49,7 @@ namespace SqlSugar bool IsAny(Expression> whereExpression); bool Update(Expression> columns, Expression> whereExpression); + bool UpdateSetColumnsTrue(Expression> columns, Expression> whereExpression); bool Update(T updateObj); bool UpdateRange(List updateObjs); bool UpdateRange(T[] updateObjs); @@ -83,6 +84,7 @@ namespace SqlSugar Task InsertReturnEntityAsync(T insertObj); Task IsAnyAsync(Expression> whereExpression); + Task UpdateSetColumnsTrueAsync(Expression> columns, Expression> whereExpression); Task UpdateAsync(Expression> columns, Expression> whereExpression); Task UpdateAsync(T updateObj); Task UpdateRangeAsync(List updateObjs); diff --git a/Src/Asp.Net/SqlSugar/SimpleClient.cs b/Src/Asp.Net/SqlSugar/SimpleClient.cs index 66199282e..c56819d4c 100644 --- a/Src/Asp.Net/SqlSugar/SimpleClient.cs +++ b/Src/Asp.Net/SqlSugar/SimpleClient.cs @@ -212,6 +212,10 @@ namespace SqlSugar { return this.Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommand() > 0; } + public virtual bool UpdateSetColumnsTrue(Expression> columns, Expression> whereExpression) + { + return this.Context.Updateable().SetColumns(columns,true).Where(whereExpression).ExecuteCommand() > 0; + } public virtual bool Delete(T deleteObj) { return this.Context.Deleteable().Where(deleteObj).ExecuteCommand() > 0; @@ -342,6 +346,10 @@ namespace SqlSugar { return await this.Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommandAsync() > 0; } + public virtual async Task UpdateSetColumnsTrueAsync(Expression> columns, Expression> whereExpression) + { + return await this.Context.Updateable().SetColumns(columns,true).Where(whereExpression).ExecuteCommandAsync() > 0; + } public virtual async Task DeleteAsync(T deleteObj) { return await this.Context.Deleteable().Where(deleteObj).ExecuteCommandAsync() > 0;