@ -59,8 +59,8 @@ namespace Admin.Core.Repository
public async Task < TEntity > QueryByIdAsync ( object objId )
{
//return await Task.Run(() => _db. Queryable<TEntity>().InSingle(objId));
return await _db . Queryable< TEntity > ( ) . In ( objId ) . SingleAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().InSingle(objId));
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . In ( objId ) . SingleAsync ( ) ;
}
/// <summary>
/// 功能描述:根据ID查询一条数据
@ -71,8 +71,8 @@ namespace Admin.Core.Repository
/// <returns>数据实体</returns>
public async Task < TEntity > QueryByIdAsync ( object objId , bool blnUseCache = false )
{
//return await Task.Run(() => _db. Queryable<TEntity>().WithCacheIF(blnUseCache).InSingle(objId));
return await _db . Queryable< TEntity > ( ) . WithCacheIF ( blnUseCache ) . In ( objId ) . SingleAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().WithCacheIF(blnUseCache).InSingle(objId));
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . WithCacheIF ( blnUseCache ) . In ( objId ) . SingleAsync ( ) ;
}
/// <summary>
@ -83,8 +83,8 @@ namespace Admin.Core.Repository
/// <returns>数据实体列表</returns>
public async Task < List < TEntity > > QueryByIDsAsync ( object [ ] lstIds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().In(lstIds).ToList());
return await _db . Queryable< TEntity > ( ) . In ( lstIds ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().In(lstIds).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . In ( lstIds ) . ToListAsync ( ) ;
}
/// <summary>
@ -94,11 +94,11 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < int > 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();
@ -115,7 +115,7 @@ namespace Admin.Core.Repository
/// <returns>返回自增量列</returns>
public async Task < int > AddAsync ( TEntity entity , Expression < Func < TEntity , object > > insertColumns = null )
{
var insert = _db . Insertable( entity ) ;
var insert = _db . CopyNew( ) . Insertable( entity ) ;
if ( insertColumns = = null )
{
return await insert . ExecuteReturnIdentityAsync ( ) ;
@ -133,7 +133,7 @@ namespace Admin.Core.Repository
/// <returns>影响行数</returns>
public async Task < int > AddAsync ( List < TEntity > listEntity )
{
return await _db . Insertable( listEntity . ToArray ( ) ) . ExecuteCommandAsync ( ) ;
return await _db . CopyNew( ) . Insertable( listEntity . ToArray ( ) ) . ExecuteCommandAsync ( ) ;
}
/// <summary>
@ -144,27 +144,27 @@ namespace Admin.Core.Repository
public async Task < bool > 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 < bool > 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 < bool > 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 < bool > UpdateAsync ( object operateAnonymousObjects )
{
return await _db . Updateable< TEntity > ( operateAnonymousObjects ) . ExecuteCommandAsync ( ) > 0 ;
return await _db . CopyNew( ) . Updateable< TEntity > ( operateAnonymousObjects ) . ExecuteCommandAsync ( ) > 0 ;
}
public async Task < bool > UpdateAsync (
@ -174,7 +174,7 @@ namespace Admin.Core.Repository
string strWhere = ""
)
{
//IUpdateable<TEntity> up = await Task.Run(() => _db. Updateable(entity));
//IUpdateable<TEntity> up = await Task.Run(() => _db. CopyNew(). Updateable(entity));
//if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0)
//{
// up = await Task.Run(() => up.IgnoreColumns(it => lstIgnoreColumns.Contains(it)));
@ -189,7 +189,7 @@ namespace Admin.Core.Repository
//}
//return await Task.Run(() => up.ExecuteCommand()) > 0;
IUpdateable < TEntity > up = _db . Updateable( entity ) ;
IUpdateable < TEntity > up = _db . CopyNew( ) . Updateable( entity ) ;
if ( lstIgnoreColumns ! = null & & lstIgnoreColumns . Count > 0 )
{
up = up . IgnoreColumns ( lstIgnoreColumns . ToArray ( ) ) ;
@ -210,7 +210,7 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < TEntity > FirstAsync ( )
{
return await _db . Queryable< TEntity > ( ) . FirstAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . FirstAsync ( ) ;
}
/// <summary>
/// 查询第一条数据
@ -219,7 +219,7 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < TEntity > FirstAsync ( Expression < Func < TEntity , bool > > whereExpression )
{
return await _db . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . FirstAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . FirstAsync ( ) ;
}
/// <summary>
/// 根据实体删除一条数据
@ -228,9 +228,9 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < bool > 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 ( ) ;
}
/// <summary>
@ -240,9 +240,9 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < bool > DeleteByIdAsync ( object id )
{
//var i = await Task.Run(() => _db. Deleteable<TEntity>(id).ExecuteCommand());
//var i = await Task.Run(() => _db. CopyNew(). Deleteable<TEntity>(id).ExecuteCommand());
//return i > 0;
return await _db . Deleteable< TEntity > ( id ) . ExecuteCommandHasChangeAsync ( ) ;
return await _db . CopyNew( ) . Deleteable< TEntity > ( id ) . ExecuteCommandHasChangeAsync ( ) ;
}
/// <summary>
@ -252,9 +252,9 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < bool > DeletesAsync ( List < TEntity > entitys )
{
//var i = await Task.Run(() => _db. Deleteable<TEntity>().In(ids).ExecuteCommand());
//var i = await Task.Run(() => _db. CopyNew(). Deleteable<TEntity>().In(ids).ExecuteCommand());
//return i > 0;
return await _db . Deleteable< TEntity > ( entitys ) . ExecuteCommandHasChangeAsync ( ) ;
return await _db . CopyNew( ) . Deleteable< TEntity > ( entitys ) . ExecuteCommandHasChangeAsync ( ) ;
}
/// <summary>
@ -264,7 +264,7 @@ namespace Admin.Core.Repository
/// <returns>数据列表</returns>
public async Task < List < TEntity > > QueryAsync ( )
{
return await _db . Queryable< TEntity > ( ) . ToListAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . ToListAsync ( ) ;
}
/// <summary>
@ -275,8 +275,8 @@ namespace Admin.Core.Repository
/// <returns>数据列表</returns>
public async Task < List < TEntity > > QueryAsync ( string strWhere )
{
//return await Task.Run(() => _db. Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db . Queryable< TEntity > ( ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToListAsync ( ) ;
}
/// <summary>
@ -287,7 +287,7 @@ namespace Admin.Core.Repository
/// <returns>数据列表</returns>
public async Task < List < TEntity > > QueryAsync ( Expression < Func < TEntity , bool > > whereExpression )
{
return await _db . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToListAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToListAsync ( ) ;
}
/// <summary>
@ -299,7 +299,7 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < List < TResult > > QueryAsync < TResult > ( Expression < Func < TEntity , TResult > > expression )
{
return await _db . Queryable< TEntity > ( ) . Select ( expression ) . ToListAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . Select ( expression ) . ToListAsync ( ) ;
}
/// <summary>
@ -313,7 +313,7 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < List < TResult > > QueryAsync < TResult > ( Expression < Func < TEntity , TResult > > expression , Expression < Func < TEntity , bool > > whereExpression , string strOrderByFileds )
{
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Select ( expression ) . ToListAsync ( ) ;
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Select ( expression ) . ToListAsync ( ) ;
}
/// <summary>
@ -325,8 +325,8 @@ namespace Admin.Core.Repository
/// <returns>数据列表</returns>
public async Task < List < TEntity > > QueryAsync ( Expression < Func < TEntity , bool > > whereExpression , string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . OrderByIF ( strOrderByFileds ! = null , strOrderByFileds ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . OrderByIF ( strOrderByFileds ! = null , strOrderByFileds ) . ToListAsync ( ) ;
}
/// <summary>
/// 功能描述:查询一个列表
@ -337,8 +337,8 @@ namespace Admin.Core.Repository
/// <returns></returns>
public async Task < List < TEntity > > QueryAsync ( Expression < Func < TEntity , bool > > whereExpression , Expression < Func < TEntity , object > > orderByExpression , bool isAsc = true )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db . Queryable< TEntity > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , isAsc ? OrderByType . Asc : OrderByType . Desc ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , isAsc ? OrderByType . Asc : OrderByType . Desc ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToListAsync ( ) ;
}
/// <summary>
@ -350,8 +350,8 @@ namespace Admin.Core.Repository
/// <returns>数据列表</returns>
public async Task < List < TEntity > > QueryAsync ( string strWhere , string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToListAsync ( ) ;
}
@ -368,8 +368,8 @@ namespace Admin.Core.Repository
int intTop ,
string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Take ( intTop ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Take ( intTop ) . ToListAsync ( ) ;
}
/// <summary>
@ -385,8 +385,8 @@ namespace Admin.Core.Repository
int intTop ,
string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . Take ( intTop ) . ToListAsync ( ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . Take ( intTop ) . ToListAsync ( ) ;
}
/// <summary>
@ -397,7 +397,7 @@ namespace Admin.Core.Repository
/// <returns>泛型集合</returns>
public async Task < List < TEntity > > QuerySqlAsync ( string strSql , SugarParameter [ ] parameters = null )
{
return await _db . Ado. SqlQueryAsync < TEntity > ( strSql , parameters ) ;
return await _db . CopyNew( ) . Ado. SqlQueryAsync < TEntity > ( strSql , parameters ) ;
}
/// <summary>
@ -408,7 +408,7 @@ namespace Admin.Core.Repository
/// <returns>泛型集合</returns>
public async Task < int > ExecSqlAsync ( string strSql , SugarParameter [ ] parameters = null )
{
return await _db . Ado. ExecuteCommandAsync ( strSql , parameters ) ;
return await _db . CopyNew( ) . Ado. ExecuteCommandAsync ( strSql , parameters ) ;
}
/// <summary>
@ -419,7 +419,7 @@ namespace Admin.Core.Repository
/// <returns>DataTable</returns>
public async Task < DataTable > QueryTableAsync ( string strSql , SugarParameter [ ] parameters = null )
{
return await _db . Ado. GetDataTableAsync ( strSql , parameters ) ;
return await _db . CopyNew( ) . Ado. GetDataTableAsync ( strSql , parameters ) ;
}
/// <summary>
@ -437,8 +437,8 @@ namespace Admin.Core.Repository
int intPageSize ,
string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToPageListAsync ( intPageIndex , intPageSize ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToPageListAsync ( intPageIndex , intPageSize ) ;
}
/// <summary>
@ -457,8 +457,8 @@ namespace Admin.Core.Repository
string strOrderByFileds )
{
//return await Task.Run(() => _db. Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return await _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToPageListAsync ( intPageIndex , intPageSize ) ;
//return await Task.Run(() => _db. CopyNew(). Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return await _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToPageListAsync ( intPageIndex , intPageSize ) ;
}
@ -475,7 +475,7 @@ namespace Admin.Core.Repository
{
RefAsync < int > totalCount = 0 ;
var list = await _db . Queryable< TEntity > ( )
var list = await _db . CopyNew( ) . Queryable< TEntity > ( )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )
. ToPageListAsync ( intPageIndex , intPageSize , totalCount ) ;
@ -503,9 +503,9 @@ namespace Admin.Core.Repository
{
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 ( ) ;
}
@ -532,7 +532,7 @@ namespace Admin.Core.Repository
{
RefAsync < int > totalCount = 0 ;
var list = await _db . Queryable< T , T2 > ( joinExpression )
var list = await _db . CopyNew( ) . Queryable< T , T2 > ( joinExpression )
. Select ( selectExpression )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )
@ -565,7 +565,7 @@ namespace Admin.Core.Repository
{
RefAsync < int > totalCount = 0 ;
var list = await _db . Queryable< T , T2 > ( joinExpression ) . GroupBy ( groupExpression )
var list = await _db . CopyNew( ) . Queryable< T , T2 > ( joinExpression ) . GroupBy ( groupExpression )
. Select ( selectExpression )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )
@ -580,7 +580,7 @@ namespace Admin.Core.Repository
public TEntity QueryById ( object objId )
{
return _db . Queryable< TEntity > ( ) . In ( objId ) . Single ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . In ( objId ) . Single ( ) ;
}
/// <summary
/// 功能描述:根据ID查询一条数据
@ -591,7 +591,7 @@ namespace Admin.Core.Repository
/// <returns数据实体</returns
public TEntity QueryById ( object objId , bool blnUseCache = false )
{
return _db . Queryable< TEntity > ( ) . WithCacheIF ( blnUseCache ) . In ( objId ) . Single ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . WithCacheIF ( blnUseCache ) . In ( objId ) . Single ( ) ;
}
/// <summary
@ -602,7 +602,7 @@ namespace Admin.Core.Repository
/// <returns数据实体列表</returns
public List < TEntity > QueryByIDs ( object [ ] lstIds )
{
return _db . Queryable< TEntity > ( ) . In ( lstIds ) . ToList ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . In ( lstIds ) . ToList ( ) ;
}
/// <summary
@ -612,7 +612,7 @@ namespace Admin.Core.Repository
/// <returns</returns
public int Add ( TEntity entity )
{
var insert = _db . Insertable( entity ) ;
var insert = _db . CopyNew( ) . Insertable( entity ) ;
return insert . ExecuteReturnIdentity ( ) ;
}
@ -626,7 +626,7 @@ namespace Admin.Core.Repository
/// <returns返回自增量列</returns
public int Add ( TEntity entity , Expression < Func < TEntity , object > > insertColumns = null )
{
var insert = _db . Insertable( entity ) ;
var insert = _db . CopyNew( ) . Insertable( entity ) ;
if ( insertColumns = = null )
{
return insert . ExecuteReturnIdentity ( ) ;
@ -644,7 +644,7 @@ namespace Admin.Core.Repository
/// <returns影响行数</returns
public int Add ( List < TEntity > listEntity )
{
return _db . Insertable( listEntity . ToArray ( ) ) . ExecuteCommand ( ) ;
return _db . CopyNew( ) . Insertable( listEntity . ToArray ( ) ) . ExecuteCommand ( ) ;
}
/// <summary
@ -655,27 +655,27 @@ namespace Admin.Core.Repository
public bool Update ( TEntity entity )
{
////这种方式会以主键为条件
//var i = Task.Run(() = _db. Updateable(entity).ExecuteCommand());
//var i = Task.Run(() = _db. CopyNew(). Updateable(entity).ExecuteCommand());
//return i 0;
//这种方式会以主键为条件
return _db . Updateable( entity ) . ExecuteCommandHasChange ( ) ;
return _db . CopyNew( ) . Updateable( entity ) . ExecuteCommandHasChange ( ) ;
}
public bool Update ( TEntity entity , string strWhere )
{
//return Task.Run(() = _db. Updateable(entity).Where(strWhere).ExecuteCommand() 0);
return _db . Updateable( entity ) . Where ( strWhere ) . ExecuteCommandHasChange ( ) ;
//return Task.Run(() = _db. CopyNew(). Updateable(entity).Where(strWhere).ExecuteCommand() 0);
return _db . CopyNew( ) . Updateable( entity ) . Where ( strWhere ) . ExecuteCommandHasChange ( ) ;
}
public bool Update ( string strSql , SugarParameter [ ] parameters = null )
{
//return Task.Run(() = _db. Ado.ExecuteCommand(strSql, parameters) 0);
return _db . Ado. ExecuteCommand ( strSql , parameters ) > 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< TEntity > ( operateAnonymousObjects ) . ExecuteCommand ( ) > 0 ;
return _db . CopyNew( ) . Updateable< TEntity > ( operateAnonymousObjects ) . ExecuteCommand ( ) > 0 ;
}
public bool Update (
@ -686,7 +686,7 @@ namespace Admin.Core.Repository
)
{
IUpdateable < TEntity > up = _db . Updateable( entity ) ;
IUpdateable < TEntity > up = _db . CopyNew( ) . Updateable( entity ) ;
if ( lstIgnoreColumns ! = null & & lstIgnoreColumns . Count > 0 )
{
up = up . IgnoreColumns ( lstIgnoreColumns . ToArray ( ) ) ;
@ -709,9 +709,9 @@ namespace Admin.Core.Repository
/// <returns</returns
public bool Delete ( TEntity entity )
{
//var i = Task.Run(() = _db. Deleteable(entity).ExecuteCommand());
//var i = Task.Run(() = _db. CopyNew(). Deleteable(entity).ExecuteCommand());
//return i 0;
return _db . Deleteable( entity ) . ExecuteCommandHasChange ( ) ;
return _db . CopyNew( ) . Deleteable( entity ) . ExecuteCommandHasChange ( ) ;
}
/// <summary
@ -721,9 +721,9 @@ namespace Admin.Core.Repository
/// <returns</returns
public bool DeleteById ( object id )
{
//var i = Task.Run(() = _db. Deleteable<TEntity(id).ExecuteCommand());
//var i = Task.Run(() = _db. CopyNew(). Deleteable<TEntity(id).ExecuteCommand());
//return i 0;
return _db . Deleteable< TEntity > ( id ) . ExecuteCommandHasChange ( ) ;
return _db . CopyNew( ) . Deleteable< TEntity > ( id ) . ExecuteCommandHasChange ( ) ;
}
/// <summary
@ -733,9 +733,9 @@ namespace Admin.Core.Repository
/// <returns</returns
public bool Deletes ( List < TEntity > entitys )
{
//var i = Task.Run(() = _db. Deleteable<TEntity().In(ids).ExecuteCommand());
//var i = Task.Run(() = _db. CopyNew(). Deleteable<TEntity().In(ids).ExecuteCommand());
//return i 0;
return _db . Deleteable< TEntity > ( entitys ) . ExecuteCommandHasChange ( ) ;
return _db . CopyNew( ) . Deleteable< TEntity > ( entitys ) . ExecuteCommandHasChange ( ) ;
}
@ -747,7 +747,7 @@ namespace Admin.Core.Repository
/// <returns数据列表</returns
public List < TEntity > Query ( )
{
return _db . Queryable< TEntity > ( ) . ToList ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . ToList ( ) ;
}
/// <summary
@ -758,8 +758,8 @@ namespace Admin.Core.Repository
/// <returns数据列表</returns
public List < TEntity > Query ( string strWhere )
{
//return Task.Run(() = _db. Queryable<TEntity().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return _db . Queryable< TEntity > ( ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToList ( ) ;
}
/// <summary
@ -770,7 +770,7 @@ namespace Admin.Core.Repository
/// <returns数据列表</returns
public List < TEntity > Query ( Expression < Func < TEntity , bool > > whereExpression )
{
return _db . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToList ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToList ( ) ;
}
/// <summary
@ -782,7 +782,7 @@ namespace Admin.Core.Repository
/// <returns</returns
public List < TResult > Query < TResult > ( Expression < Func < TEntity , TResult > > expression )
{
return _db . Queryable< TEntity > ( ) . Select ( expression ) . ToList ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . Select ( expression ) . ToList ( ) ;
}
/// <summary
@ -796,7 +796,7 @@ namespace Admin.Core.Repository
/// <returns</returns
public List < TResult > Query < TResult > ( Expression < Func < TEntity , TResult > > expression , Expression < Func < TEntity , bool > > whereExpression , string strOrderByFileds )
{
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Select ( expression ) . ToList ( ) ;
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Select ( expression ) . ToList ( ) ;
}
/// <summary
@ -808,8 +808,8 @@ namespace Admin.Core.Repository
/// <returns数据列表</returns
public List < TEntity > Query ( Expression < Func < TEntity , bool > > whereExpression , string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return _db . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . OrderByIF ( strOrderByFileds ! = null , strOrderByFileds ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return _db . CopyNew( ) . Queryable< TEntity > ( ) . WhereIF ( whereExpression ! = null , whereExpression ) . OrderByIF ( strOrderByFileds ! = null , strOrderByFileds ) . ToList ( ) ;
}
/// <summary
/// 功能描述:查询一个列表
@ -820,8 +820,8 @@ namespace Admin.Core.Repository
/// <returns</returns
public List < TEntity > Query ( Expression < Func < TEntity , bool > > whereExpression , Expression < Func < TEntity , object > > orderByExpression , bool isAsc = true )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList());
return _db . Queryable< TEntity > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , isAsc ? OrderByType . Asc : OrderByType . Desc ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). 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
@ -833,8 +833,8 @@ namespace Admin.Core.Repository
/// <returns数据列表</returns
public List < TEntity > Query ( string strWhere , string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToList ( ) ;
}
@ -851,8 +851,8 @@ namespace Admin.Core.Repository
int intTop ,
string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Take ( intTop ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . Take ( intTop ) . ToList ( ) ;
}
/// <summary
@ -868,8 +868,8 @@ namespace Admin.Core.Repository
int intTop ,
string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . Take ( intTop ) . ToList ( ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . Take ( intTop ) . ToList ( ) ;
}
/// <summary
@ -880,7 +880,7 @@ namespace Admin.Core.Repository
/// <returns泛型集合</returns
public List < TEntity > QuerySql ( string strSql , SugarParameter [ ] parameters = null )
{
return _db . Ado. SqlQuery < TEntity > ( strSql , parameters ) ;
return _db . CopyNew( ) . Ado. SqlQuery < TEntity > ( strSql , parameters ) ;
}
/// <summary
@ -891,7 +891,7 @@ namespace Admin.Core.Repository
/// <returns泛型集合</returns
public int ExecSql ( string strSql , SugarParameter [ ] parameters = null )
{
return _db . Ado. ExecuteCommand ( strSql , parameters ) ;
return _db . CopyNew( ) . Ado. ExecuteCommand ( strSql , parameters ) ;
}
/// <summary
@ -902,7 +902,7 @@ namespace Admin.Core.Repository
/// <returnsDataTable</returns
public DataTable QueryTable ( string strSql , SugarParameter [ ] parameters = null )
{
return _db . Ado. GetDataTable ( strSql , parameters ) ;
return _db . CopyNew( ) . Ado. GetDataTable ( strSql , parameters ) ;
}
/// <summary
@ -920,8 +920,8 @@ namespace Admin.Core.Repository
int intPageSize ,
string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToPageList ( intPageIndex , intPageSize ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( whereExpression ! = null , whereExpression ) . ToPageList ( intPageIndex , intPageSize ) ;
}
/// <summary
@ -940,8 +940,8 @@ namespace Admin.Core.Repository
string strOrderByFileds )
{
//return Task.Run(() = _db. Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return _db . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToPageList ( intPageIndex , intPageSize ) ;
//return Task.Run(() = _db. CopyNew(). Queryable<TEntity().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return _db . CopyNew( ) . Queryable< TEntity > ( ) . OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds ) . WhereIF ( ! string . IsNullOrEmpty ( strWhere ) , strWhere ) . ToPageList ( intPageIndex , intPageSize ) ;
}
@ -958,7 +958,7 @@ namespace Admin.Core.Repository
{
int totalCount = 0 ;
var list = _db . Queryable< TEntity > ( )
var list = _db . CopyNew( ) . Queryable< TEntity > ( )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )
. ToPageList ( intPageIndex , intPageSize , ref totalCount ) ;
@ -986,9 +986,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 ( ) ;
}
@ -1015,7 +1015,7 @@ namespace Admin.Core.Repository
{
int totalCount = 0 ;
var list = _db . Queryable< T , T2 > ( joinExpression )
var list = _db . CopyNew( ) . Queryable< T , T2 > ( joinExpression )
. Select ( selectExpression )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )
@ -1048,7 +1048,7 @@ namespace Admin.Core.Repository
{
int totalCount = 0 ;
var list = _db . Queryable< T , T2 > ( joinExpression ) . GroupBy ( groupExpression )
var list = _db . CopyNew( ) . Queryable< T , T2 > ( joinExpression ) . GroupBy ( groupExpression )
. Select ( selectExpression )
. OrderByIF ( ! string . IsNullOrEmpty ( strOrderByFileds ) , strOrderByFileds )
. WhereIF ( whereExpression ! = null , whereExpression )