Ejemplo n.º 1
0
 public int Delete(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Deleteable(entity).ExecuteCommand();
         return(result);
     }
 }
Ejemplo n.º 2
0
 public int Delete(IEnumerable <int> ids)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Deleteable <T>(ids).ExecuteCommand();
         return(result);
     }
 }
Ejemplo n.º 3
0
 public bool AddReturnBool(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(entity).ExecuteCommandIdentityIntoEntity();
         return(result);
     }
 }
Ejemplo n.º 4
0
 public int AddBatch(IEnumerable <T> list)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(list.ToArray()).ExecuteCommand();
         return(result);
     }
 }
Ejemplo 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);
     }
 }
Ejemplo n.º 6
0
 public T AddReturnEntity(T entity)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Insertable(entity).ExecuteReturnEntity();
         return(result);
     }
 }
Ejemplo 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);
     }
 }
Ejemplo n.º 8
0
 public T QueryById(int id)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <T>().InSingle(id);
         return(result);
     }
 }
Ejemplo n.º 9
0
 public IEnumerable <T> QueryTop(int top)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <T>().Take(top).ToList();
         return(result);
     }
 }
Ejemplo n.º 10
0
 public int ModifyBatch(List <T> list)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Updateable(list).ExecuteCommand();
         return(result);
     }
 }
Ejemplo n.º 11
0
 public List <int> GetTestCreateUserId()
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var userIdList = db.Queryable <TbfT0Combination>().Where(m => m.CreateUserTime < Convert.ToDateTime("2018-12-12")).Select(m => m.CreateUserId).ToList();
         var result     = userIdList.Distinct().ToList();
         return(result);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 根据用户ID获取 该用户创建组合的 组合GUID
 /// </summary>
 /// <param name="createUserId"></param>
 /// <returns></returns>
 public List <string> GetCombinationByCreateId(int createUserId)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <TbfT0Combination>().Where(m => m.CreateUserId == createUserId)
                      .Select(m => m.Guid).ToList();
         return(result);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 获得T0Combination表中所有的用户id,去重
 /// </summary>
 /// <returns></returns>
 public List <int> GetAllCreateUserId()
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var userIdList = db.Queryable <TbfT0Combination>().Select(m => m.CreateUserId).ToList();
         var result     = userIdList.Distinct().ToList();
         return(result);
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 根据组合中的guid得到stockCode
 /// </summary>
 /// <param name="guid"></param>
 /// <returns></returns>
 public List <string> GetStockCodeByGuidList(string guid)
 {
     using (var db = SqlSugarFactory.GetInstance())
     {
         var result = db.Queryable <TbfT0CombinationFund>().Where(m => m.Guid == guid).Select(m => m.StockCode)
                      .ToList();
         return(result);
     }
 }
Ejemplo n.º 15
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);
         }
     }
 }