public int Delete(T entity) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Deleteable(entity).ExecuteCommand(); return(result); } }
public int Delete(IEnumerable <int> ids) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Deleteable <T>(ids).ExecuteCommand(); return(result); } }
public bool AddReturnBool(T entity) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Insertable(entity).ExecuteCommandIdentityIntoEntity(); return(result); } }
public int AddBatch(IEnumerable <T> list) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Insertable(list.ToArray()).ExecuteCommand(); return(result); } }
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); } }
public T AddReturnEntity(T entity) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Insertable(entity).ExecuteReturnEntity(); return(result); } }
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); } }
public T QueryById(int id) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Queryable <T>().InSingle(id); return(result); } }
public IEnumerable <T> QueryTop(int top) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Queryable <T>().Take(top).ToList(); return(result); } }
public int ModifyBatch(List <T> list) { using (var db = SqlSugarFactory.GetInstance()) { var result = db.Updateable(list).ExecuteCommand(); return(result); } }
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); } }
/// <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); } }
/// <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); } }
/// <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); } }
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); } } }