mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 增加 FreeSql.DbContext DbSet Remove 可根据 lambda 条件删除数据的方法;
This commit is contained in:
parent
06fba16b4a
commit
f7633e9f67
@ -377,6 +377,16 @@ namespace FreeSql
|
||||
_db._entityChangeReport.AddRange(dels.Select(a => new DbContext.EntityChangeReport.ChangeInfo { Object = a.Value, Type = DbContext.EntityChangeType.Delete }));
|
||||
return Math.Max(dels.Length, affrows);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据 lambda 条件删除数据
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
async public Task<int> RemoveAsync(Expression<Func<TEntity, bool>> predicate)
|
||||
{
|
||||
await DbContextExecCommandAsync();
|
||||
return await this.OrmDelete(null).Where(predicate).ExecuteAffrowsAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddOrUpdateAsync
|
||||
|
@ -410,6 +410,16 @@ namespace FreeSql
|
||||
EnqueueToDbContext(DbContext.EntityChangeType.Delete, state);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据 lambda 条件删除数据
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public int Remove(Expression<Func<TEntity, bool>> predicate)
|
||||
{
|
||||
DbContextExecCommand();
|
||||
return this.OrmDelete(null).Where(predicate).ExecuteAffrows();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddOrUpdate
|
||||
|
Loading…
x
Reference in New Issue
Block a user