using System.Linq.Expressions; using SqlSugar; namespace KH.WMS.Core.Database.Repositories; /// /// 仓储接口 /// /// 实体类型 public interface IRepository where T : class where TKey : struct { /// /// 根据ID获取实体 /// Task GetByIdAsync(TKey id); /// /// 获取所有实体 /// Task> GetAllAsync(); /// /// 根据条件查询实体 /// Task> GetListAsync(Expression> expression); /// /// 根据条件查询单个实体 /// Task GetFirstOrDefaultAsync(Expression> expression); /// /// 分页查询 /// Task<(List Items, int Total)> GetPagedListAsync(int pageIndex, int pageSize, Expression>? expression = null); /// /// 插入实体 /// Task InsertAsync(T entity); /// /// 批量插入实体 /// Task> InsertAsync(List entities); /// /// /// /// /// Task InsertReturnEntityAsync(T entity); /// /// /// /// /// Task> InsertReturnEntityAsync(List entities); /// /// 更新实体 /// Task UpdateAsync(T entity); /// /// 批量更新实体 /// Task UpdateAsync(List entities); /// /// 删除实体 /// Task DeleteAsync(TKey id); /// /// 批量删除实体 /// Task DeleteAsync(List ids); /// /// 根据条件删除实体 /// Task DeleteAsync(Expression> expression); /// /// 检查实体是否存在 /// Task ExistsAsync(Expression> expression); /// /// 获取实体数量 /// Task CountAsync(Expression>? expression = null); }