using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq.Expressions; using System.Threading.Tasks; namespace Repository { public interface IRepository { DbContext GetCurrentDbContext(); /// /// 添加实体 /// /// /// /// bool Add(T entity) where T : class; /// /// 异步实现 /// /// /// /// Task AddAsync(T entity) where T : class; /// /// 批量的进行添加实体 /// /// /// /// bool AddRange(IEnumerable entity) where T : class; /// /// 批量的进行添加实体 /// /// /// /// Task AddRangeAsync(IEnumerable entity) where T : class; /// /// 删除单个实体 /// /// /// /// bool Delete(T entity) where T : class; /// /// 删除所有 /// /// /// bool DeleteAll() where T : class; /// /// 异步删除所有 /// /// /// Task DeleteAllAsync() where T : class; /// /// 根据查询条件进行删除单个实体 /// /// /// /// bool Delete(Expression> whereLambda) where T : class; /// /// 根据查询条件进行异步删除单个实体 /// /// /// /// Task DeleteAsync(Expression> whereLambda) where T : class; bool DeleteById(dynamic id) where T : class; Task DeleteByIdAsync(dynamic id) where T : class; /// ///单个对象的修改 /// /// /// 需要修改的对象 /// bool Update(T entity) where T : class; Task UpdateAsync(T entity) where T : class; /// /// 批量修改 /// /// /// /// /// /// bool Update(Expression> whereLambda, Expression> updateLambda) where T : class; /// /// 异步批量修改 /// /// /// /// /// /// Task UpdateAsync(Expression> whereLambda, Expression> updateLambda) where T : class; /// /// 批量的修改 /// /// /// /// bool Update(List entity) where T : class; /// /// 批量统一的进行更新 /// /// /// 需要修改的对象实体 /// 查询的条件 /// /// bool Update(T model, Expression> whereLambda, params string[] modifiedProNames) where T : class; /// /// 根据主键进行查询 /// /// /// /// T FindById(dynamic id) where T : class; /// /// 根据主键进行查询异步 /// /// /// /// Task FindByIdAsync(dynamic id) where T : class; /// /// 默认查询选择第一条数据,没有那么进行返回NULL /// /// /// /// 返回bool T GetFirstDefault(Expression> whereLambda = null) where T : class; Task GetFirstDefaultAsync(Expression> whereLambda = null) where T : class; /// /// 查询所有的数据 /// /// /// List GetAll(string orderProperty) where T : class; /// /// 查询所有的数据 /// /// /// Task> GetAllAsync(string orderProperty) where T : class; /// /// 含有带条件的查询 /// /// /// Include Path /// /// List GetAllQuery(string path,Expression> whereLambda = null) where T : class; /// /// 含有带条件的查询 /// /// /// /// List GetAllQuery(Expression> whereLambda = null) where T : class; /// /// 异步含有带条件的查询 /// /// /// /// Task> GetAllQueryAsync(Expression> whereLambda = null) where T : class; /// ///获取查询的数量 /// /// /// /// int GetCount(Expression> whereLambda = null) where T : class; /// ///异步获取查询的数量 /// /// /// /// Task GetCountAsync(Expression> whereLambda = null) where T : class; /// /// 判断对象是否存在 /// /// /// /// bool GetAny(Expression> whereLambda = null) where T : class; /// /// 异步判断对象是否存在 /// /// /// /// Task GetAnyAsync(Expression> whereLambda = null) where T : class; /// /// 根据查询过条件进行分页 /// /// /// /// 当前页面 /// 页面的大小 /// 排序的条件 /// 查询条件 /// 是否正序 /// List Pagination(int pageIndex, int pageSize, Expression> orderBy, Expression> whereLambda = null, bool isOrder = true) where T : class; /// /// 异步根据查询过条件进行分页 /// /// /// /// 当前页面 /// 页面的大小 /// 排序的条件 /// 查询条件 /// 是否正序 /// Task> PaginationAsync(int pageIndex, int pageSize, Expression> orderBy, Expression> whereLambda = null, bool isOrder = true) where T : class; /// /// 根据查询条件进行做分页查询 /// /// 查询的对象 /// 当前的页码 /// 每页的大小 /// 排序条件 /// 查询条件 /// List Pagination(int pageIndex, int pageSize, string ordering, Expression> whereLambda = null) where T : class; /// /// 根据查询条件进行转化 /// /// /// /// List GetSelect(Expression> whereLambda) where T : class; /// /// 执行存储过程或自定义sql语句--返回集合 /// /// /// /// /// /// List QueryPro(string sql, List parameters, CommandType cmdType = CommandType.Text) where T : class; /// /// 回滚 /// /// void RollBackChanges() where T : class; } }