@ -28,14 +28,25 @@ namespace SqlSugar
{
return Context . Queryable < T > ( ) . ToList ( ) ;
}
public T GetSingle < T > ( Expression < Func < T , bool > > whereExpression ) where T : class , new ( )
{
return Context . Queryable < T > ( ) . Single ( whereExpression ) ;
}
public List < T > GetList < T > ( Expression < Func < T , bool > > whereExpression ) where T : class , new ( )
{
return Context . Queryable < T > ( ) . Where ( whereExpression ) . ToList ( ) ;
}
public List < T > GetPageList < T > ( Expression < Func < T , bool > > whereExpression , PageModel page ) where T : class , new ( )
public List < T > GetPageList < T > ( Expression < Func < T , bool > > whereExpression , PageModel page ) where T : class , new ( )
{
int count = 0 ;
var result = Context . Queryable < T > ( ) . Where ( whereExpression ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
var result = Context . Queryable < T > ( ) . Where ( whereExpression ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
page . PageCount = count ;
return result ;
}
public List < T > GetPageList < T > ( Expression < Func < T , bool > > whereExpression , PageModel page , Expression < Func < T , object > > orderByExpression = null , OrderByType orderByType = OrderByType . Asc ) where T : class , new ( )
{
int count = 0 ;
var result = Context . Queryable < T > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , orderByType ) . Where ( whereExpression ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
page . PageCount = count ;
return result ;
}
@ -46,6 +57,13 @@ namespace SqlSugar
page . PageCount = count ;
return result ;
}
public List < T > GetPageList < T > ( List < IConditionalModel > conditionalList , PageModel page , Expression < Func < T , object > > orderByExpression = null , OrderByType orderByType = OrderByType . Asc ) where T : class , new ( )
{
int count = 0 ;
var result = Context . Queryable < T > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , orderByType ) . Where ( conditionalList ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
page . PageCount = count ;
return result ;
}
public bool IsAny < T > ( Expression < Func < T , bool > > whereExpression ) where T : class , new ( )
{
return Context . Queryable < T > ( ) . Where ( whereExpression ) . Any ( ) ;
@ -70,6 +88,10 @@ namespace SqlSugar
{
return this . Context . Updateable ( updateObj ) . ExecuteCommand ( ) > 0 ;
}
public bool UpdateRange < T > ( T [ ] updateObjs ) where T : class , new ( )
{
return this . Context . Updateable ( updateObjs ) . ExecuteCommand ( ) > 0 ;
}
public bool Update < T > ( Expression < Func < T , T > > columns , Expression < Func < T , bool > > whereExpression ) where T : class , new ( )
{
return this . Context . Updateable < T > ( ) . UpdateColumns ( columns ) . Where ( whereExpression ) . ExecuteCommand ( ) > 0 ;
@ -109,7 +131,7 @@ namespace SqlSugar
{
return Context . Queryable < T > ( ) . InSingle ( id ) ;
}
public List < T > GetList ( )
public List < T > GetList ( )
{
return Context . Queryable < T > ( ) . ToList ( ) ;
}
@ -117,6 +139,10 @@ namespace SqlSugar
{
return Context . Queryable < T > ( ) . Where ( whereExpression ) . ToList ( ) ;
}
public T GetSingle ( Expression < Func < T , bool > > whereExpression )
{
return Context . Queryable < T > ( ) . Single ( whereExpression ) ;
}
public List < T > GetPageList ( Expression < Func < T , bool > > whereExpression , PageModel page )
{
int count = 0 ;
@ -124,6 +150,13 @@ namespace SqlSugar
page . PageCount = count ;
return result ;
}
public List < T > GetPageList ( Expression < Func < T , bool > > whereExpression , PageModel page , Expression < Func < T , object > > orderByExpression = null , OrderByType orderByType = OrderByType . Asc )
{
int count = 0 ;
var result = Context . Queryable < T > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , orderByType ) . Where ( whereExpression ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
page . PageCount = count ;
return result ;
}
public List < T > GetPageList ( List < IConditionalModel > conditionalList , PageModel page )
{
int count = 0 ;
@ -131,19 +164,32 @@ namespace SqlSugar
page . PageCount = count ;
return result ;
}
public List < T > GetPageList ( List < IConditionalModel > conditionalList , PageModel page , Expression < Func < T , object > > orderByExpression = null , OrderByType orderByType = OrderByType . Asc )
{
int count = 0 ;
var result = Context . Queryable < T > ( ) . OrderByIF ( orderByExpression ! = null , orderByExpression , orderByType ) . Where ( conditionalList ) . ToPageList ( page . PageIndex , page . PageSize , ref count ) ;
page . PageCount = count ;
return result ;
}
public bool IsAny ( Expression < Func < T , bool > > whereExpression )
{
return Context . Queryable < T > ( ) . Where ( whereExpression ) . Any ( ) ;
}
public bool Insert ( T insertObj )
public int Count ( Expression < Func < T , bool > > whereExpression )
{
return Context . Queryable < T > ( ) . Where ( whereExpression ) . Count ( ) ;
}
public bool Insert ( T insertObj )
{
return this . Context . Insertable ( insertObj ) . ExecuteCommand ( ) > 0 ;
}
public int InsertReturnIdentity ( T insertObj )
public int InsertReturnIdentity ( T insertObj )
{
return this . Context . Insertable ( insertObj ) . ExecuteReturnIdentity ( ) ;
}
public bool InsertRange ( T [ ] insertObjs )
public bool InsertRange ( T [ ] insertObjs )
{
return this . Context . Insertable ( insertObjs ) . ExecuteCommand ( ) > 0 ;
}
@ -151,11 +197,15 @@ namespace SqlSugar
{
return this . Context . Insertable ( insertObjs ) . ExecuteCommand ( ) > 0 ;
}
public bool Update ( T updateObj )
public bool Update ( T updateObj )
{
return this . Context . Updateable ( updateObj ) . ExecuteCommand ( ) > 0 ;
}
public bool Update ( Expression < Func < T , T > > columns , Expression < Func < T , bool > > whereExpression )
public bool UpdateRange ( T [ ] updateObjs )
{
return this . Context . Updateable ( updateObjs ) . ExecuteCommand ( ) > 0 ;
}
public bool Update ( Expression < Func < T , T > > columns , Expression < Func < T , bool > > whereExpression )
{
return this . Context . Updateable < T > ( ) . UpdateColumns ( columns ) . Where ( whereExpression ) . ExecuteCommand ( ) > 0 ;
}
@ -163,11 +213,11 @@ namespace SqlSugar
{
return this . Context . Deleteable < T > ( ) . Where ( deleteObj ) . ExecuteCommand ( ) > 0 ;
}
public bool Delete ( Expression < Func < T , bool > > whereExpression )
public bool Delete ( Expression < Func < T , bool > > whereExpression )
{
return this . Context . Deleteable < T > ( ) . Where ( whereExpression ) . ExecuteCommand ( ) > 0 ;
}
public bool DeleteById ( dynamic id )
public bool DeleteById ( dynamic id )
{
return this . Context . Deleteable < T > ( ) . In ( id ) . ExecuteCommand ( ) > 0 ;
}