24 lines
899 B
C#
24 lines
899 B
C#
using System.Linq.Expressions;
|
|
|
|
namespace F9WebAiTest.Domain.Common;
|
|
|
|
/// <summary>通用仓储接口</summary>
|
|
public interface IRepository<T> where T : IEntity
|
|
{
|
|
Task<T> GetByIdAsync(long id);
|
|
Task<List<T>> GetAllAsync();
|
|
Task<List<T>> FindAsync(Expression<Func<T, bool>> predicate);
|
|
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
|
Task<bool> AnyAsync(Expression<Func<T, bool>> predicate);
|
|
Task<long> CountAsync(Expression<Func<T, bool>> predicate);
|
|
Task<T> AddAsync(T entity);
|
|
Task AddRangeAsync(IEnumerable<T> entities);
|
|
Task UpdateAsync(T entity);
|
|
Task DeleteAsync(T entity);
|
|
Task DeleteRangeAsync(IEnumerable<T> entities);
|
|
// 物理删除(不软删除,用于关联表避免唯一索引冲突)
|
|
Task HardDeleteAsync(T entity);
|
|
Task HardDeleteRangeAsync(IEnumerable<T> entities);
|
|
Task<int> SaveChangesAsync();
|
|
}
|