using Admin.Core.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; using System.Threading.Tasks; namespace Admin.Core.IService { public interface IBaseServices<TEntity> where TEntity : class { bool GetConnectionState(); Task<TEntity> QueryByIdAsync(object objId); Task<TEntity> QueryByIdAsync(object objId, bool blnUseCache = false); Task<List<TEntity>> QueryByIDsAsync(object[] lstIds); Task<int> AddAsync(TEntity model); Task<int> AddAsync(List<TEntity> listEntity); Task<bool> DeleteByIdAsync(object id); Task<bool> DeleteAsync(TEntity model); Task<bool> DeletesAsync(List<TEntity> entitys); Task<bool> UpdateAsync(TEntity model); Task<bool> UpdateAsync(TEntity entity, string strWhere); Task<bool> UpdateAsync(object operateAnonymousObjects); Task<bool> UpdateAsync(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = ""); /// <summary> /// 正序查询第一条数据 /// </summary> /// <returns></returns> Task<TEntity> FirstAsync(); /// <summary> /// 根据条件查询查询第一条数据 /// </summary> /// <param name="whereExpression"></param> /// <returns></returns> Task<TEntity> FirstAsync(Expression<Func<TEntity, bool>> whereExpression); Task<List<TEntity>> QueryAsync(); Task<List<TEntity>> QueryAsync(string strWhere); Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression); Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds); Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, TResult>> expression); Task<List<TResult>> QueryAsync<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression,string strOrderByFileds); Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true); Task<List<TEntity>> QueryAsync(string strWhere, string strOrderByFileds); Task<List<TEntity>> QuerySqlAsync(string strSql, SugarParameter[] parameters = null); Task<DataTable> QueryTableAsync(string strSql, SugarParameter[] parameters = null); Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds); Task<List<TEntity>> QueryAsync(string strWhere, int intTop, string strOrderByFileds); Task<List<TEntity>> QueryAsync( Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); Task<List<TEntity>> QueryAsync(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); Task<PageModel<TEntity>> QueryPageAsync(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); Task<List<TResult>> QueryMuchAsync<T, T2, T3, TResult>( Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new(); List<TEntity> Query(Expression<Func<TEntity, bool>> whereExpression); } }