Exemplo n.º 1
0
 public int Delete(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Deleteable(entity).ExecuteCommand();
         return(result);
     }
 }
Exemplo n.º 2
0
 public int Delete(IEnumerable <int> ids)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Deleteable <T>(ids).ExecuteCommand();
         return(result);
     }
 }
Exemplo n.º 3
0
 public bool AddReturnBool(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(entity).ExecuteCommandIdentityIntoEntity();
         return(result);
     }
 }
Exemplo n.º 4
0
 public int AddBatch(IEnumerable <T> list)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(list.ToArray()).ExecuteCommand();
         return(result);
     }
 }
Exemplo n.º 5
0
 public IEnumerable <T> QueryByIfPage(Expression <Func <T, object> > orderBy, int orderType, Expression <Func <T, bool> > where, int pageIndex, int pageSize, ref int totalCount)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var list = db.Queryable <T>().WhereIF(true, where).OrderBy(orderBy, (OrderByType)orderType).ToPageList(pageIndex, pageSize, ref totalCount);
         return(list);
     }
 }
Exemplo n.º 6
0
 public T AddReturnEntity(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(entity).ExecuteReturnEntity();
         return(result);
     }
 }
Exemplo n.º 7
0
 public IEnumerable <T> QueryPage(Expression <Func <T, object> > orderBy, int orderType, int pageIndex, int pageSize, ref int totalCount)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <T>().OrderBy(orderBy, (OrderByType)orderType).ToPageList(pageIndex, pageSize, ref totalCount);
         return(result);
     }
 }
Exemplo n.º 8
0
 public T QueryById(int id)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <T>().InSingle(id);
         return(result);
     }
 }
Exemplo n.º 9
0
 public IEnumerable <T> QueryTop(int top)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <T>().Take(top).ToList();
         return(result);
     }
 }
Exemplo n.º 10
0
 public int ModifyBatch(List <T> list)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Updateable(list).ExecuteCommand();
         return(result);
     }
 }
Exemplo n.º 11
0
 public IEnumerable <T> QueryByIf(Expression <Func <T, bool> > where)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         if (where != null)
         {
             var list = db.Queryable <T>().WhereIF(true, where).ToList();
             return(list);
         }
         else
         {
             var list = db.Queryable <T>().ToList();
             return(list);
         }
     }
 }