刘磊
2024-12-21 a6ea79849f0142b5280f0c5d4b15ecc83f0d015a
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs
@@ -22,7 +22,7 @@
    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
        {
@@ -84,7 +84,7 @@
        /// <returns>查询结果</returns>
        public virtual TEntity QureyDataById(object id)
        {
            return _db.Queryable<TEntity>().In(id).Single();
            return _db.CopyNew().Queryable<TEntity>().In(id).Single();
        }
        /// <summary>
@@ -94,7 +94,7 @@
        /// <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>
@@ -104,7 +104,7 @@
        /// <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>
@@ -114,7 +114,7 @@
        /// <returns>影响行数</returns>
        public virtual int AddData(TEntity entity)
        {
            IInsertable<TEntity> insert = _db.Insertable(entity);
            IInsertable<TEntity> insert = _db.CopyNew().Insertable(entity);
            return insert.ExecuteReturnIdentity();
        }
@@ -125,7 +125,7 @@
        /// <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();
        }
@@ -136,7 +136,7 @@
        /// <returns>删除结果</returns>
        public virtual bool DeleteDataById(object id)
        {
            return _db.Deleteable<TEntity>().In(id).ExecuteCommandHasChange();
            return _db.CopyNew().Deleteable<TEntity>().In(id).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -146,7 +146,7 @@
        /// <returns>删除结果</returns>
        public virtual bool DeleteDataByIds(object[] ids)
        {
            return _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChange();
            return _db.CopyNew().Deleteable<TEntity>().In(ids).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -156,7 +156,7 @@
        /// <returns>删除结果</returns>
        public virtual bool DeleteData(TEntity entity)
        {
            return _db.Deleteable(entity).ExecuteCommandHasChange();
            return _db.CopyNew().Deleteable(entity).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -166,7 +166,7 @@
        /// <returns>删除结果</returns>
        public virtual bool DeleteData(List<TEntity> listEntity)
        {
            return _db.Deleteable(listEntity).ExecuteCommandHasChange();
            return _db.CopyNew().Deleteable(listEntity).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -176,7 +176,7 @@
        /// <returns></returns>
        public virtual bool UpdateData(TEntity entity)
        {
            return _db.Updateable(entity).ExecuteCommandHasChange();
            return _db.CopyNew().Updateable(entity).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -186,7 +186,7 @@
        /// <returns></returns>
        public virtual bool UpdateData(List<TEntity> listEntity)
        {
            return _db.Updateable(listEntity).ExecuteCommandHasChange();
            return _db.CopyNew().Updateable(listEntity).ExecuteCommandHasChange();
        }
        /// <summary>
@@ -198,7 +198,7 @@
        /// <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)
            {
@@ -219,7 +219,7 @@
        /// <returns></returns>
        public virtual List<TEntity> QueryData()
        {
            return _db.Queryable<TEntity>().ToList();
            return _db.CopyNew().Queryable<TEntity>().ToList();
        }
        /// <summary>
@@ -229,7 +229,7 @@
        /// <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>
@@ -239,17 +239,17 @@
        /// <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>
@@ -270,7 +270,7 @@
                };
                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>
@@ -291,7 +291,7 @@
                };
                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>
@@ -302,7 +302,7 @@
        /// <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>
@@ -315,7 +315,7 @@
        /// <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>
@@ -327,7 +327,7 @@
        /// <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>
@@ -338,7 +338,7 @@
        /// <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>
@@ -405,7 +405,7 @@
        /// <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>
@@ -417,7 +417,7 @@
        /// <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>
@@ -430,7 +430,7 @@
        /// <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);
        }
@@ -444,7 +444,7 @@
        /// <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);
        }
@@ -459,7 +459,7 @@
        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);
@@ -488,7 +488,7 @@
                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);
@@ -517,7 +517,7 @@
                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);
@@ -539,7 +539,7 @@
           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;
@@ -560,7 +560,7 @@
        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)
@@ -585,7 +585,7 @@
        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)
@@ -595,64 +595,64 @@
        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)
            {
@@ -669,27 +669,27 @@
        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)
@@ -704,7 +704,7 @@
                };
                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)
@@ -719,7 +719,7 @@
                };
                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)
@@ -734,7 +734,7 @@
                };
                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)
@@ -749,12 +749,12 @@
                };
                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)
@@ -769,27 +769,27 @@
                };
                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)
@@ -819,29 +819,29 @@
        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();
        }