diff --git a/Admin.Core.Repository/BASE/BaseRepository.cs b/Admin.Core.Repository/BASE/BaseRepository.cs index 4d220e1e..bd14d2ed 100644 --- a/Admin.Core.Repository/BASE/BaseRepository.cs +++ b/Admin.Core.Repository/BASE/BaseRepository.cs @@ -36,6 +36,14 @@ namespace Admin.Core.Repository } } + //输入最终SQL语句... + //_db.Aop.OnLogExecuting = (sql, pars) => + //{ + // //var s1 = sql;//断点打在这里看内部生成的sql语句... + // Console.Write(sql); + //}; + + return _dbBase; } } @@ -83,7 +91,7 @@ namespace Admin.Core.Repository public async Task QueryByIdAsync(object objId) { if (GetConnectionState() == false) return null; - return await _db.Queryable().In(objId).SingleAsync(); + return await _db.CopyNew().Queryable().In(objId).SingleAsync(); } /// /// 功能描述:根据ID查询一条数据 @@ -95,7 +103,7 @@ namespace Admin.Core.Repository public async Task QueryByIdAsync(object objId, bool blnUseCache = false) { if (GetConnectionState() == false) return null; - return await _db.Queryable().WithCacheIF(blnUseCache).In(objId).SingleAsync(); + return await _db.CopyNew().Queryable().WithCacheIF(blnUseCache).In(objId).SingleAsync(); } /// @@ -107,7 +115,7 @@ namespace Admin.Core.Repository public async Task> QueryByIDsAsync(object[] lstIds) { if (GetConnectionState() == false) return null; - return await _db.Queryable().In(lstIds).ToListAsync(); + return await _db.CopyNew().Queryable().In(lstIds).ToListAsync(); } /// @@ -117,11 +125,11 @@ namespace Admin.Core.Repository /// public async Task AddAsync(TEntity entity) { - //var i = await Task.Run(() => _db.Insertable(entity).ExecuteReturnBigIdentity()); + //var i = await Task.Run(() => _db.CopyNew().Insertable(entity).ExecuteReturnBigIdentity()); ////返回的i是long类型,这里你可以根据你的业务需要进行处理 //return (int)i; - var insert = _db.Insertable(entity); + var insert = _db.CopyNew().Insertable(entity); //这里你可以返回TEntity,这样的话就可以获取id值,无论主键是什么类型 //var return3 = await insert.ExecuteReturnEntityAsync(); @@ -138,7 +146,7 @@ namespace Admin.Core.Repository /// 返回自增量列 public async Task AddAsync(TEntity entity, Expression> insertColumns = null) { - var insert = _db.Insertable(entity); + var insert = _db.CopyNew().Insertable(entity); if (insertColumns == null) { return await insert.ExecuteReturnIdentityAsync(); @@ -156,7 +164,7 @@ namespace Admin.Core.Repository /// 影响行数 public async Task AddAsync(List listEntity) { - return await _db.Insertable(listEntity.ToArray()).ExecuteCommandAsync(); + return await _db.CopyNew().Insertable(listEntity.ToArray()).ExecuteCommandAsync(); } /// @@ -167,27 +175,27 @@ namespace Admin.Core.Repository public async Task UpdateAsync(TEntity entity) { ////这种方式会以主键为条件 - //var i = await Task.Run(() => _db.Updateable(entity).ExecuteCommand()); + //var i = await Task.Run(() => _db.CopyNew().Updateable(entity).ExecuteCommand()); //return i > 0; //这种方式会以主键为条件 - return await _db.Updateable(entity).ExecuteCommandHasChangeAsync(); + return await _db.CopyNew().Updateable(entity).ExecuteCommandHasChangeAsync(); } public async Task UpdateAsync(TEntity entity, string strWhere) { - //return await Task.Run(() => _db.Updateable(entity).Where(strWhere).ExecuteCommand() > 0); - return await _db.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync(); + //return await Task.Run(() => _db.CopyNew().Updateable(entity).Where(strWhere).ExecuteCommand() > 0); + return await _db.CopyNew().Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync(); } public async Task UpdateAsync(string strSql, SugarParameter[] parameters = null) { - //return await Task.Run(() => _db.Ado.ExecuteCommand(strSql, parameters) > 0); - return await _db.Ado.ExecuteCommandAsync(strSql, parameters) > 0; + //return await Task.Run(() => _db.CopyNew().Ado.ExecuteCommand(strSql, parameters) > 0); + return await _db.CopyNew().Ado.ExecuteCommandAsync(strSql, parameters) > 0; } public async Task UpdateAsync(object operateAnonymousObjects) { - return await _db.Updateable(operateAnonymousObjects).ExecuteCommandAsync() > 0; + return await _db.CopyNew().Updateable(operateAnonymousObjects).ExecuteCommandAsync() > 0; } public async Task UpdateAsync( @@ -197,7 +205,7 @@ namespace Admin.Core.Repository string strWhere = "" ) { - //IUpdateable up = await Task.Run(() => _db.Updateable(entity)); + //IUpdateable up = await Task.Run(() => _db.CopyNew().Updateable(entity)); //if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) //{ // up = await Task.Run(() => up.IgnoreColumns(it => lstIgnoreColumns.Contains(it))); @@ -212,7 +220,7 @@ namespace Admin.Core.Repository //} //return await Task.Run(() => up.ExecuteCommand()) > 0; - IUpdateable up = _db.Updateable(entity); + IUpdateable up = _db.CopyNew().Updateable(entity); if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) { up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); @@ -234,7 +242,7 @@ namespace Admin.Core.Repository public async Task FirstAsync() { if (GetConnectionState() == false) return null; - return await _db.Queryable().FirstAsync(); + return await _db.CopyNew().Queryable().FirstAsync(); } /// /// 查询第一条数据 @@ -244,7 +252,7 @@ namespace Admin.Core.Repository public async Task FirstAsync(Expression> whereExpression) { if (GetConnectionState() == false) return null; - return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).FirstAsync(); + return await _db.CopyNew().Queryable().WhereIF(whereExpression != null, whereExpression).FirstAsync(); } /// /// 根据实体删除一条数据 @@ -253,9 +261,9 @@ namespace Admin.Core.Repository /// public async Task DeleteAsync(TEntity entity) { - //var i = await Task.Run(() => _db.Deleteable(entity).ExecuteCommand()); + //var i = await Task.Run(() => _db.CopyNew().Deleteable(entity).ExecuteCommand()); //return i > 0; - return await _db.Deleteable(entity).ExecuteCommandHasChangeAsync(); + return await _db.CopyNew().Deleteable(entity).ExecuteCommandHasChangeAsync(); } /// @@ -265,9 +273,9 @@ namespace Admin.Core.Repository /// public async Task DeleteByIdAsync(object id) { - //var i = await Task.Run(() => _db.Deleteable(id).ExecuteCommand()); + //var i = await Task.Run(() => _db.CopyNew().Deleteable(id).ExecuteCommand()); //return i > 0; - return await _db.Deleteable(id).ExecuteCommandHasChangeAsync(); + return await _db.CopyNew().Deleteable(id).ExecuteCommandHasChangeAsync(); } /// @@ -277,9 +285,9 @@ namespace Admin.Core.Repository /// public async Task DeletesAsync(List entitys) { - //var i = await Task.Run(() => _db.Deleteable().In(ids).ExecuteCommand()); + //var i = await Task.Run(() => _db.CopyNew().Deleteable().In(ids).ExecuteCommand()); //return i > 0; - return await _db.Deleteable(entitys).ExecuteCommandHasChangeAsync(); + return await _db.CopyNew().Deleteable(entitys).ExecuteCommandHasChangeAsync(); } /// @@ -292,7 +300,7 @@ namespace Admin.Core.Repository try { if (GetConnectionState() == false) return null; - return await _db.Queryable().ToListAsync(); + return await _db.CopyNew().Queryable().ToListAsync(); }catch(Exception ex) { Console.WriteLine($"QueryAsync执行异常:{ex.Message}"); @@ -309,8 +317,8 @@ namespace Admin.Core.Repository public async Task> QueryAsync(string strWhere) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); - return await _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.CopyNew().Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); } /// @@ -322,7 +330,7 @@ namespace Admin.Core.Repository public async Task> QueryAsync(Expression> whereExpression) { if (GetConnectionState() == false) return null; - return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).ToListAsync(); + return await _db.CopyNew().Queryable().WhereIF(whereExpression != null, whereExpression).ToListAsync(); } /// @@ -335,7 +343,7 @@ namespace Admin.Core.Repository public async Task> QueryAsync(Expression> expression) { if (GetConnectionState() == false) return null; - return await _db.Queryable().Select(expression).ToListAsync(); + return await _db.CopyNew().Queryable().Select(expression).ToListAsync(); } /// @@ -350,7 +358,7 @@ namespace Admin.Core.Repository public async Task> QueryAsync(Expression> expression, Expression> whereExpression, string strOrderByFileds) { if (GetConnectionState() == false) return null; - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync(); } /// @@ -363,8 +371,8 @@ namespace Admin.Core.Repository public async Task> QueryAsync(Expression> whereExpression, string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList()); - return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList()); + return await _db.CopyNew().Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync(); } /// /// 功能描述:查询一个列表 @@ -376,8 +384,8 @@ namespace Admin.Core.Repository public async Task> QueryAsync(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList()); - return await _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList()); + return await _db.CopyNew().Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); } /// @@ -390,8 +398,8 @@ namespace Admin.Core.Repository public async Task> QueryAsync(string strWhere, string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); } @@ -409,8 +417,8 @@ namespace Admin.Core.Repository string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList()); - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList()); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync(); } /// @@ -427,8 +435,8 @@ namespace Admin.Core.Repository string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList()); - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync(); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList()); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync(); } /// @@ -440,7 +448,7 @@ namespace Admin.Core.Repository public async Task> QuerySqlAsync(string strSql, SugarParameter[] parameters = null) { if (GetConnectionState() == false) return null; - return await _db.Ado.SqlQueryAsync(strSql, parameters); + return await _db.CopyNew().Ado.SqlQueryAsync(strSql, parameters); } /// @@ -451,7 +459,7 @@ namespace Admin.Core.Repository /// 泛型集合 public async Task ExecSqlAsync(string strSql, SugarParameter[] parameters = null) { - return await _db.Ado.ExecuteCommandAsync(strSql, parameters); + return await _db.CopyNew().Ado.ExecuteCommandAsync(strSql, parameters); } /// @@ -463,7 +471,7 @@ namespace Admin.Core.Repository public async Task QueryTableAsync(string strSql, SugarParameter[] parameters = null) { if (GetConnectionState() == false) return null; - return await _db.Ado.GetDataTableAsync(strSql, parameters); + return await _db.CopyNew().Ado.GetDataTableAsync(strSql, parameters); } /// @@ -482,8 +490,8 @@ namespace Admin.Core.Repository string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize)); - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize)); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize); } /// @@ -503,8 +511,8 @@ namespace Admin.Core.Repository string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize)); - return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize); + //return await Task.Run(() => _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize)); + return await _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize); } @@ -522,7 +530,7 @@ namespace Admin.Core.Repository if (GetConnectionState() == false) return null; RefAsync totalCount = 0; - var list = await _db.Queryable() + var list = await _db.CopyNew().Queryable() .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression) .ToPageListAsync(intPageIndex, intPageSize, totalCount); @@ -551,9 +559,9 @@ namespace Admin.Core.Repository if (GetConnectionState() == false) return null; if (whereLambda == null) { - return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + return await _db.CopyNew().Queryable(joinExpression).Select(selectExpression).ToListAsync(); } - return await _db.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).ToListAsync(); + return await _db.CopyNew().Queryable(joinExpression).Where(whereLambda).Select(selectExpression).ToListAsync(); } @@ -580,7 +588,7 @@ namespace Admin.Core.Repository { if (GetConnectionState() == false) return null; RefAsync totalCount = 0; - var list = await _db.Queryable(joinExpression) + var list = await _db.CopyNew().Queryable(joinExpression) .Select(selectExpression) .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression) @@ -614,7 +622,7 @@ namespace Admin.Core.Repository if (GetConnectionState() == false) return null; RefAsync totalCount = 0; - var list = await _db.Queryable(joinExpression).GroupBy(groupExpression) + var list = await _db.CopyNew().Queryable(joinExpression).GroupBy(groupExpression) .Select(selectExpression) .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression) @@ -629,7 +637,7 @@ namespace Admin.Core.Repository public TEntity QueryById(object objId) { - return _db.Queryable().In(objId).Single(); + return _db.CopyNew().Queryable().In(objId).Single(); } /// ().WithCacheIF(blnUseCache).In(objId).Single(); + return _db.CopyNew().Queryable().WithCacheIF(blnUseCache).In(objId).Single(); } /// QueryByIDs(object[] lstIds) { - return _db.Queryable().In(lstIds).ToList(); + return _db.CopyNew().Queryable().In(lstIds).ToList(); } /// > insertColumns = null) { - var insert = _db.Insertable(entity); + var insert = _db.CopyNew().Insertable(entity); if (insertColumns == null) { return insert.ExecuteReturnIdentity(); @@ -706,7 +714,7 @@ namespace Admin.Core.Repository /// listEntity) { - return _db.Insertable(listEntity.ToArray()).ExecuteCommand(); + return _db.CopyNew().Insertable(listEntity.ToArray()).ExecuteCommand(); } /// 0; + //return Task.Run(() = _db.CopyNew().Ado.ExecuteCommand(strSql, parameters) 0); + return _db.CopyNew().Ado.ExecuteCommand(strSql, parameters) > 0; } public bool Update(object operateAnonymousObjects) { - return _db.Updateable(operateAnonymousObjects).ExecuteCommand() > 0; + return _db.CopyNew().Updateable(operateAnonymousObjects).ExecuteCommand() > 0; } public bool Update( @@ -748,7 +756,7 @@ namespace Admin.Core.Repository ) { - IUpdateable up = _db.Updateable(entity); + IUpdateable up = _db.CopyNew().Updateable(entity); if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) { up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); @@ -771,9 +779,9 @@ namespace Admin.Core.Repository /// (id).ExecuteCommandHasChange(); + return _db.CopyNew().Deleteable(id).ExecuteCommandHasChange(); } /// entitys) { - //var i = Task.Run(() = _db.Deleteable(entitys).ExecuteCommandHasChange(); + return _db.CopyNew().Deleteable(entitys).ExecuteCommandHasChange(); } @@ -810,7 +818,7 @@ namespace Admin.Core.Repository public List Query() { if (GetConnectionState() == false) return null; - return _db.Queryable().ToList(); + return _db.CopyNew().Queryable().ToList(); } /// Query(string strWhere) { if (GetConnectionState() == false) return null; - //return Task.Run(() = _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList(); } /// Query(Expression> whereExpression) { if (GetConnectionState() == false) return null; - return _db.Queryable().WhereIF(whereExpression != null, whereExpression).ToList(); + return _db.CopyNew().Queryable().WhereIF(whereExpression != null, whereExpression).ToList(); } /// Query(Expression> expression) { if (GetConnectionState() == false) return null; - return _db.Queryable().Select(expression).ToList(); + return _db.CopyNew().Queryable().Select(expression).ToList(); } /// Query(Expression> expression, Expression> whereExpression, string strOrderByFileds) { if (GetConnectionState() == false) return null; - return _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); + return _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Select(expression).ToList(); } /// Query(Expression> whereExpression, string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return Task.Run(() = _db.Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToList(); } /// Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) { if (GetConnectionState() == false) return null; - //return Task.Run(() = _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList(); } /// Query(string strWhere, string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return Task.Run(() = _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList(); } @@ -922,8 +930,8 @@ namespace Admin.Core.Repository string strOrderByFileds) { if (GetConnectionState() == false) return null; - //return Task.Run(() = _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList(); } /// ().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList(); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList(); } /// QuerySql(string strSql, SugarParameter[] parameters = null) { - return _db.Ado.SqlQuery(strSql, parameters); + return _db.CopyNew().Ado.SqlQuery(strSql, parameters); } /// ().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize); } /// ().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize); + //return Task.Run(() = _db.CopyNew().Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize); } @@ -1029,7 +1037,7 @@ namespace Admin.Core.Repository { int totalCount = 0; - var list = _db.Queryable() + var list = _db.CopyNew().Queryable() .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression) .ToPageList(intPageIndex, intPageSize, ref totalCount); @@ -1057,9 +1065,9 @@ namespace Admin.Core.Repository { if (whereLambda == null) { - return _db.Queryable(joinExpression).Select(selectExpression).ToList(); + return _db.CopyNew().Queryable(joinExpression).Select(selectExpression).ToList(); } - return _db.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).ToList(); + return _db.CopyNew().Queryable(joinExpression).Where(whereLambda).Select(selectExpression).ToList(); } @@ -1086,7 +1094,7 @@ namespace Admin.Core.Repository { int totalCount = 0; - var list = _db.Queryable(joinExpression) + var list = _db.CopyNew().Queryable(joinExpression) .Select(selectExpression) .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression) @@ -1119,7 +1127,7 @@ namespace Admin.Core.Repository { int totalCount = 0; - var list = _db.Queryable(joinExpression).GroupBy(groupExpression) + var list = _db.CopyNew().Queryable(joinExpression).GroupBy(groupExpression) .Select(selectExpression) .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) .WhereIF(whereExpression != null, whereExpression)