| | |
| | | public class RepositoryBase<TEntity> : IRepository<TEntity> where TEntity : class, new() |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly SqlSugarClient _dbBase; |
| | | private readonly SqlSugarScope _dbBase; |
| | | |
| | | private ISqlSugarClient _db |
| | | { |
| | |
| | | /// <returns>查询结果</returns> |
| | | public virtual TEntity QureyDataById(object id) |
| | | { |
| | | return _db.Queryable<TEntity>().In(id).Single(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(id).Single(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>查询结果集合</returns> |
| | | public virtual List<TEntity> QureyDataByIds(object[] lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>查询结果集合</returns> |
| | | public virtual List<TEntity> QureyDataByIds(List<object> lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>影响行数</returns> |
| | | public virtual int AddData(TEntity entity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(entity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(entity); |
| | | return insert.ExecuteReturnIdentity(); |
| | | } |
| | | |
| | |
| | | /// <returns>影响行数</returns> |
| | | public virtual int AddData(List<TEntity> listEntity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(listEntity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(listEntity); |
| | | return insert.ExecuteCommand(); |
| | | } |
| | | |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteDataById(object id) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(id).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(id).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteDataByIds(object[] ids) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(ids).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteData(TEntity entity) |
| | | { |
| | | return _db.Deleteable(entity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable(entity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>删除结果</returns> |
| | | public virtual bool DeleteData(List<TEntity> listEntity) |
| | | { |
| | | return _db.Deleteable(listEntity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Deleteable(listEntity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(TEntity entity) |
| | | { |
| | | return _db.Updateable(entity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Updateable(entity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(List<TEntity> listEntity) |
| | | { |
| | | return _db.Updateable(listEntity).ExecuteCommandHasChange(); |
| | | return _db.CopyNew().Updateable(listEntity).ExecuteCommandHasChange(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual bool UpdateData(TEntity entity, List<string> lstColumns, List<string>? lstIgnoreColumns = null) |
| | | { |
| | | IUpdateable<TEntity> update = _db.Updateable(entity); |
| | | IUpdateable<TEntity> update = _db.CopyNew().Updateable(entity); |
| | | |
| | | if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData() |
| | | { |
| | | return _db.Queryable<TEntity>().ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | } |
| | | |
| | | public virtual TEntity QueryFirst(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).First(); |
| | | } |
| | | |
| | | public virtual TResult QueryFirst<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).First(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TResult> QueryData<TResult>(Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().Select(expression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().Select(expression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TResult> QueryData<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields = "") |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToList(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression).ToPageList(pageIndex, pageSize); |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public virtual List<TEntity> QueryData(string where, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).ToPageList(pageIndex, pageSize); |
| | | } |
| | | |
| | |
| | | public virtual PageGridData<TEntity> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | var list = _db.Queryable<TEntity>() |
| | | var list = _db.CopyNew().Queryable<TEntity>() |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | | .ToPageList(pageIndex, pageSize, ref totalCount); |
| | |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | int totalCount = 0; |
| | | List<TEntity> list = _db.Queryable<TEntity>() |
| | | List<TEntity> list = _db.CopyNew().Queryable<TEntity>() |
| | | .OrderBy(orderByModels) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | | .ToPageList(pageIndex, pageSize, ref totalCount); |
| | |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | int totalCount = 0; |
| | | List<TEntity> list = _db.Queryable<TEntity>() |
| | | List<TEntity> list = _db.CopyNew().Queryable<TEntity>() |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToPageList(pageIndex, pageSize, ref totalCount); |
| | | |
| | | return new PageGridData<TEntity>(totalCount, list); |
| | |
| | | Expression<Func<T,T2, bool>> whereExpressionT1, |
| | | Expression<Func<TResult, bool>> whereExpression) |
| | | { |
| | | List<TResult> list = _db.Queryable(joinExpression).WhereIF(whereExpressionT1 != null, whereExpressionT1) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression).WhereIF(whereExpressionT1 != null, whereExpressionT1) |
| | | .Select(selectExpression) |
| | | .WhereIF(whereExpression != null, whereExpression).ToList(); |
| | | return list; |
| | |
| | | public virtual PageGridData<TResult> QueryTabsPage<T1, T2, TResult>(Expression<Func<T1, T2, object[]>> joinExpression, Expression<Func<T1, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | List<TResult> list = _db.Queryable(joinExpression) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression) |
| | | .Select(selectExpression) |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | |
| | | public virtual PageGridData<TResult> QueryTabsPage<T1, T2, TResult>(Expression<Func<T1, T2, object[]>> joinExpression, Expression<Func<T1, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression, Expression<Func<T1, object>> groupExpression, int pageIndex, int pageSize, string? orderByFields = null) |
| | | { |
| | | int totalCount = 0; |
| | | List<TResult> list = _db.Queryable(joinExpression).GroupBy(groupExpression) |
| | | List<TResult> list = _db.CopyNew().Queryable(joinExpression).GroupBy(groupExpression) |
| | | .Select(selectExpression) |
| | | .OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression) |
| | |
| | | |
| | | public Task<TEntity> QureyDataByIdAsync(object id) |
| | | { |
| | | return _db.Queryable<TEntity>().In(id).SingleAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(id).SingleAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QureyDataByIdsAsync(object[] lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QureyDataByIdsAsync(List<object> lstIds) |
| | | { |
| | | return _db.Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().In(lstIds).ToListAsync(); |
| | | } |
| | | |
| | | public Task<int> AddDataAsync(TEntity entity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(entity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(entity); |
| | | return insert.ExecuteReturnIdentityAsync(); |
| | | } |
| | | |
| | | public Task<int> AddDataAsync(List<TEntity> listEntity) |
| | | { |
| | | IInsertable<TEntity> insert = _db.Insertable(listEntity); |
| | | IInsertable<TEntity> insert = _db.CopyNew().Insertable(listEntity); |
| | | return insert.ExecuteReturnIdentityAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataByIdAsync(object id) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(id).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(id).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataByIdsAsync(object[] ids) |
| | | { |
| | | return _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataAsync(TEntity entity) |
| | | { |
| | | return _db.Deleteable(entity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable(entity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> DeleteDataAsync(List<TEntity> listEntity) |
| | | { |
| | | return _db.Deleteable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Deleteable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(TEntity entity) |
| | | { |
| | | return _db.Updateable(entity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Updateable(entity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(List<TEntity> listEntity) |
| | | { |
| | | return _db.Updateable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | return _db.CopyNew().Updateable(listEntity).ExecuteCommandHasChangeAsync(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataAsync(TEntity entity, List<string> lstColumns, List<string>? lstIgnoreColumns = null) |
| | | { |
| | | IUpdateable<TEntity> update = _db.Updateable(entity); |
| | | IUpdateable<TEntity> update = _db.CopyNew().Updateable(entity); |
| | | |
| | | if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) |
| | | { |
| | |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync() |
| | | { |
| | | return _db.Queryable<TEntity>().ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).FirstAsync(); |
| | | } |
| | | |
| | | public Task<TResult> QueryFirstAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).Select(expression).FirstAsync(); |
| | | } |
| | | |
| | | public TResult QueryFirst<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).First(); |
| | | } |
| | | |
| | | public Task<TResult> QueryFirstAsync<TResult>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, TResult>> expression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).Select(expression).FirstAsync(); |
| | | } |
| | | |
| | | public TEntity QueryFirst(Expression<Func<TEntity, bool>> whereExpression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).First(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).First(); |
| | | } |
| | | |
| | | public Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> whereExpression, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).FirstAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).FirstAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, Dictionary<string, OrderByType> orderBy) |
| | |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | return _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).OrderBy(orderByModels).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryDataAsync<TResult>(Expression<Func<TEntity, TResult>> expression) |
| | | { |
| | | return _db.Queryable<TEntity>().Select(expression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().Select(expression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryDataAsync<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataBySqlAsync(string sql, SugarParameter[]? parameters = null) |
| | |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, int top, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToListAsync(); |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToListAsync(); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(whereExpression != null, whereExpression).ToPageListAsync(pageIndex, pageSize); |
| | | } |
| | | |
| | | public Task<List<TEntity>> QueryDataAsync(string where, int pageIndex, int pageSize, string orderByFields) |
| | | { |
| | | return _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | return _db.CopyNew().Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields) |
| | | .WhereIF(!string.IsNullOrEmpty(where), where).ToPageListAsync(pageIndex, pageSize); |
| | | } |
| | | |
| | | public Task<List<TResult>> QueryTabsAsync<T, T2, TResult>(Expression<Func<T, T2, object[]>> joinExpression, Expression<Func<T, T2, TResult>> selectExpression, Expression<Func<TResult, bool>> whereExpression) |
| | | { |
| | | return _db.Queryable(joinExpression) |
| | | return _db.CopyNew().Queryable(joinExpression) |
| | | .Select(selectExpression) |
| | | .WhereIF(whereExpression != null, whereExpression).ToListAsync(); |
| | | } |