using Infrastructure.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Linq.Expressions; namespace ZR.Service { /// /// 基础服务定义 /// /// public interface IBaseService where T : class { #region 事务 /// /// 启用事务 /// void BeginTran(); /// /// 提交事务 /// void CommitTran(); /// /// 回滚事务 /// void RollbackTran(); #endregion #region 添加操作 /// /// 添加一条数据 /// /// /// int Add(T parm); /// /// 批量添加数据 /// /// List /// int Add(List parm); /// /// 添加或更新数据 /// /// /// T Saveable(T parm, Expression> uClumns = null, Expression> iColumns = null); /// /// 批量添加或更新数据 /// /// List /// List Saveable(List parm, Expression> uClumns = null, Expression> iColumns = null); #endregion #region 查询操作 /// /// 根据条件查询数据是否存在 /// /// 条件表达式树 /// bool Any(Expression> where); /// /// 根据条件合计字段 /// /// 条件表达式树 /// TResult Sum(Expression> where, Expression> field); /// /// 根据主值查询单条数据 /// /// 主键值 /// 泛型实体 T GetId(object pkValue); /// /// 根据主键查询多条数据 /// /// /// List GetIn(object[] ids); /// /// 根据条件取条数 /// /// 条件表达式树 /// int GetCount(Expression> where); /// /// 查询所有数据(无分页,请慎用) /// /// List GetAll(bool useCache = false, int cacheSecond = 3600); /// /// 获得一条数据 /// /// Expression> /// T GetFirst(Expression> where); /// /// 获得一条数据 /// /// string /// T GetFirst(string parm); /// /// 根据条件查询分页数据 /// /// /// /// PagedInfo GetPages(Expression> where, Model.PagerInfo parm); /// /// 根据条件查询分页 /// /// /// /// /// /// PagedInfo GetPages(Expression> where, Model.PagerInfo parm, Expression> order, string orderEnum = "Asc"); /// /// 根据条件查询数据 /// /// 条件表达式树 /// List GetWhere(Expression> where, bool useCache = false, int cacheSecond = 3600); /// /// 根据条件查询数据 /// /// 条件表达式树 /// List GetWhere(Expression> where, Expression> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600); #endregion #region 修改操作 /// /// 修改一条数据 /// /// T /// int Update(T parm); /// /// 批量修改 /// /// T /// int Update(List parm); /// /// 按查询条件更新 /// /// /// /// int Update(Expression> where, Expression> columns); #endregion #region 删除操作 /// /// 删除一条或多条数据 /// /// string /// int Delete(object id); /// /// 删除一条或多条数据 /// /// string /// int Delete(object[] ids); /// /// 根据条件删除一条或多条数据 /// /// 过滤条件 /// int Delete(Expression> where); /// /// 清空表 /// /// int DeleteTable(); #endregion } }