Add UpdateSetColumnsTrue

This commit is contained in:
sunkaixuan 2022-09-29 20:50:12 +08:00
parent 71bc2a7293
commit b151954571
2 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,7 @@ namespace SqlSugar
bool IsAny(Expression<Func<T, bool>> whereExpression);
bool Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
bool UpdateSetColumnsTrue(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
bool Update(T updateObj);
bool UpdateRange(List<T> updateObjs);
bool UpdateRange(T[] updateObjs);
@ -83,6 +84,7 @@ namespace SqlSugar
Task<T> InsertReturnEntityAsync(T insertObj);
Task<bool> IsAnyAsync(Expression<Func<T, bool>> whereExpression);
Task<bool> UpdateSetColumnsTrueAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
Task<bool> UpdateAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
Task<bool> UpdateAsync(T updateObj);
Task<bool> UpdateRangeAsync(List<T> updateObjs);

View File

@ -212,6 +212,10 @@ namespace SqlSugar
{
return this.Context.Updateable<T>().SetColumns(columns).Where(whereExpression).ExecuteCommand() > 0;
}
public virtual bool UpdateSetColumnsTrue(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
{
return this.Context.Updateable<T>().SetColumns(columns,true).Where(whereExpression).ExecuteCommand() > 0;
}
public virtual bool Delete(T deleteObj)
{
return this.Context.Deleteable<T>().Where(deleteObj).ExecuteCommand() > 0;
@ -342,6 +346,10 @@ namespace SqlSugar
{
return await this.Context.Updateable<T>().SetColumns(columns).Where(whereExpression).ExecuteCommandAsync() > 0;
}
public virtual async Task<bool> UpdateSetColumnsTrueAsync(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
{
return await this.Context.Updateable<T>().SetColumns(columns,true).Where(whereExpression).ExecuteCommandAsync() > 0;
}
public virtual async Task<bool> DeleteAsync(T deleteObj)
{
return await this.Context.Deleteable<T>().Where(deleteObj).ExecuteCommandAsync() > 0;