using Tiobon.Core.Model; using SqlSugar; using System.Data; using System.Linq.Expressions; using Tiobon.Core.Common; namespace Tiobon.Core.IRepository.Base { public interface IBaseRepository where TEntity : class { /// /// SqlsugarClient实体 /// ISqlSugarClient Db { get; } /// /// 查询实体数据是否存在 /// /// /// Task AnyAsync(object objId); /// /// 查询实体数据是否存在 /// /// /// bool Any(object objId); /// /// 根据Id查询实体 /// /// /// Task QueryById(object objId); Task QueryById(object objId, bool blnUseCache = false); /// /// 根据id数组查询实体list /// /// /// Task> QueryByIDs(object[] lstIds); /// /// 添加 /// /// /// Task Add(TEntity model); /// /// 批量添加 /// /// /// Task> Add(List listEntity); /// /// 根据id 删除某一实体 /// /// /// Task DeleteById(object id); /// /// 根据对象,删除某一实体 /// /// /// Task Delete(TEntity model); /// /// 根据id数组,删除实体list /// /// /// Task DeleteByIds(object[] ids); /// /// 根据表达式,删除实体 /// /// /// Task Delete(Expression> whereExpression); /// /// 更新model /// /// /// Task Update(TEntity model); /// /// 更新model /// /// /// Task Update(List model); /// /// 根据model,更新,带where条件 /// /// /// /// Task Update(TEntity entity, string where); Task Update(object operateAnonymousObjects); /// /// 根据model,更新,指定列 /// /// /// /// /// /// Task Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string where = ""); /// /// 查询 /// /// Task> Query(); /// /// 带sql where查询 /// /// /// Task> Query(string where); /// /// 根据表达式查询 /// /// /// Task> Query(Expression> whereExpression); /// /// 根据表达式,指定返回对象模型,查询 /// /// /// /// Task> Query(Expression> expression); /// /// 根据表达式,指定返回对象模型,排序,查询 /// /// /// /// /// /// Task> Query(Expression> expression, Expression> whereExpression, string orderByFields); Task> Query(Expression> whereExpression, string orderByFields); Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); Task> Query(string where, string orderByFields); Task> Query(Expression> whereExpression, int intTop, string orderByFields); Task> Query(string where, int intTop, string orderByFields); Task> QuerySql(string sql, SugarParameter[] parameters = null); Task QueryTable(string sql, SugarParameter[] parameters = null); Task> Query( Expression> whereExpression, int pageIndex, int pageSize, string orderByFields); Task> Query(string where, int pageIndex, int pageSize, string orderByFields); /// /// 根据表达式,排序字段,分页查询 /// /// /// /// /// /// Task> QueryPage(Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); /// /// 根据表达式,排序字段,分页查询 /// /// /// /// /// /// Task> QueryFilterPage(QueryBody filter); /// /// 三表联查 /// /// /// /// /// /// /// /// /// Task> QueryMuch( Expression> joinExpression, Expression> selectExpression, Expression> whereLambda = null) where T : class, new(); /// /// 两表联查-分页 /// /// /// /// /// /// /// /// /// /// /// Task> QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); /// /// 两表联合查询-分页-分组 /// /// /// /// /// /// /// /// /// /// /// /// Task> QueryTabsPage( Expression> joinExpression, Expression> selectExpression, Expression> whereExpression, Expression> groupExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); #region 分表 /// /// 通过ID查询 /// /// /// Task QueryByIdSplit(object objId); /// /// 自动分表插入 /// /// /// Task> AddSplit(TEntity entity); /// /// 删除 /// /// /// /// Task DeleteSplit(TEntity entity, DateTime dateTime); /// /// 更新 /// /// /// /// Task UpdateSplit(TEntity entity, DateTime dateTime); /// /// 分页查询 /// /// /// /// /// /// /// /// Task> QueryPageSplit(Expression> whereExpression, DateTime beginTime, DateTime endTime, int pageIndex = 1, int pageSize = 20, string orderByFields = null); #endregion } }