mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 DbSet/Repository DeleteCascadeAsync 异步方法;
This commit is contained in:
@ -32,6 +32,9 @@ namespace FreeSql
|
||||
_dbset.RemoveRange(entitys);
|
||||
return _db.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
public virtual Task<List<object>> DeleteCascade(TEntity entity, CancellationToken cancellationToken = default) => _dbset.RemoveCascadeAsync(entity, cancellationToken);
|
||||
public virtual Task<List<object>> DeleteCascade(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default) => _dbset.RemoveRangeCascadeAsync(entitys, cancellationToken);
|
||||
public virtual Task<List<object>> DeleteCascade(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default) => _dbset.RemoveCascadeAsync(predicate, cancellationToken);
|
||||
|
||||
async public virtual Task<TEntity> InsertAsync(TEntity entity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -73,6 +76,7 @@ namespace FreeSql
|
||||
|
||||
partial class BaseRepository<TEntity, TKey>
|
||||
{
|
||||
public virtual Task<List<object>> DeleteCascadeAsync(TKey id, CancellationToken cancellationToken = default) => _dbset.RemoveCascadeAsync(Find(id), cancellationToken);
|
||||
public virtual Task<int> DeleteAsync(TKey id, CancellationToken cancellationToken = default) => DeleteAsync(CheckTKeyAndReturnIdEntity(id), cancellationToken);
|
||||
public virtual Task<TEntity> FindAsync(TKey id, CancellationToken cancellationToken = default) => _dbset.OrmSelectInternal(CheckTKeyAndReturnIdEntity(id)).ToOneAsync(cancellationToken);
|
||||
public Task<TEntity> GetAsync(TKey id, CancellationToken cancellationToken = default) => _dbset.OrmSelectInternal(CheckTKeyAndReturnIdEntity(id)).ToOneAsync(cancellationToken);
|
||||
|
@ -124,6 +124,9 @@ namespace FreeSql
|
||||
Task<int> DeleteAsync(TEntity entity, CancellationToken cancellationToken = default);
|
||||
Task<int> DeleteAsync(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default);
|
||||
Task<int> DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
|
||||
Task<List<object>> DeleteCascade(TEntity entity, CancellationToken cancellationToken = default);
|
||||
Task<List<object>> DeleteCascade(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default);
|
||||
Task<List<object>> DeleteCascade(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -140,6 +143,7 @@ namespace FreeSql
|
||||
Task<TEntity> GetAsync(TKey id, CancellationToken cancellationToken = default);
|
||||
Task<TEntity> FindAsync(TKey id, CancellationToken cancellationToken = default);
|
||||
Task<int> DeleteAsync(TKey id, CancellationToken cancellationToken = default);
|
||||
Task<List<object>> DeleteCascadeAsync(TKey id, CancellationToken cancellationToken = default);
|
||||
#endif
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user