using SqlSugar;
using System.Linq.Expressions;
using Txgy.RBS.Framework;
namespace Txgy.RBS.IServices
{
    public interface IBaseService
    {
        #region Query
        /// 
        /// 根据id查询实体
        /// 
        /// 
        /// 
        T Find(int id) where T : class;
        /// 
        /// 提供对单表的查询
        /// 
        /// ISugarQueryable类型集合
        [Obsolete("尽量避免使用,using 带表达式目录树的 代替")]
        ISugarQueryable Set() where T : class;
        /// 
        /// 查询
        /// 
        /// 
        /// 
        /// 
        ISugarQueryable Query(Expression> funcWhere) where T : class;
        /// 
        /// 分页查询
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        PagingData QueryPage(Expression> funcWhere, int pageSize, int pageIndex, Expression> funcOrderby, bool isAsc = true) where T : class;
        #endregion
        #region Add
        /// 
        /// 新增数据,即时Commit
        /// 
        /// 
        /// 返回带主键的实体
        T Insert(T t) where T : class, new();
        /// 
        /// 新增数据,即时Commit
        /// 多条sql 一个连接,事务插入
        /// 
        /// 
        IEnumerable Insert(List tList) where T : class, new();
        #endregion
        #region Update
        /// 
        /// 更新数据,即时Commit
        /// 
        /// 
        void Update(T t) where T : class, new();
        /// 
        /// 更新数据,即时Commit
        /// 
        /// 
        void Update(List tList) where T : class, new();
        #endregion
        #region Delete
        /// 
        /// 根据主键删除数据,即时Commit
        /// 
        /// 
        void Delete(int Id) where T : class, new();
        /// 
        /// 删除数据,即时Commit
        /// 
        /// 
        void Delete(T t) where T : class, new();
        /// 
        /// 删除数据,即时Commit
        /// 
        /// 
        void Delete(List tList) where T : class;
        #endregion
        #region Other
        /// 
        /// 执行sql 返回集合
        /// 
        /// 
        /// 
        /// 
        ISugarQueryable ExcuteQuery(string sql) where T : class, new();
        #endregion
    }
}