public async Task <List <TestData> > CheckSize(TestDataFilter filter) { await UpdateAvailable(); var list = _dbContext.Set <TestData>().Where(x => x.ProductSize.ToLower().Equals(filter.ProductSize.ToLower()) && x.isAvailable == Database.Enums.IsInStock.IN_STOCK).ToList(); return(await Task.FromResult(list)); }
/* To Delete multiple record at a time :) * <param name="predicate"> contains an expression like > where clause OR list */ public virtual void DeleteWhere(IEnumerable <T> list) { _dbContext.Set <T>() .RemoveRange(list); // directly contain a list of record Save(); // save changes }
/// <summary> /// get entity all collection from store /// </summary> public static List <T> GetAll <dbContext, T>() where dbContext : DbContext, new() where T : class, IbaseProperties, new() { #region to get list try { using (var sc = new dbContext()) { return(sc.Set <T>().ToList()); } } catch (Exception ex) { //MessageBox.Show(ex.Message); return(null); throw; } #endregion }
public List <T> GetAll() { using (DbContextTransaction transaction = _dbContext.Database.BeginTransaction()) { try { transaction.Commit(); var result = _dbContext.Set <T>().ToList(); return(result); //var tt = typeof(T); //var Tu = typeof(U); //var ret = _dbContext.Set<U>().AsNoTracking().ToList(); //return Mappings.Default.Map<List<T>>(ret); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); transaction.Rollback(); return(null); } } }
public GenericRepository(dbContext db) { this._dbContext = db; this._dbSet = _dbContext.Set <T>(); }
public BaseRepository(dbContext dbContext) { _dbContext = dbContext; _dbset = _dbContext.Set <T>(); }
public RepositoryBase(dbContext context) { Context = context; DbSet = context.Set <T>(); }
public void Create(TEntity entity) { _context.Set <TEntity>().Add(entity); _context.SaveChanges(); }
public BaseRepository(dbContext context) { this._context = context; this.dbSet = context.Set <TEntity>(); }
public BaseModel(dbContext context) { dbSet = context.Set <T>(); this.context = context; }
public void Excluir(T entity) { ctx.Set <T>().Remove(entity); }
/// <summary> /// get entity all collection include sub collection from store /// </summary> public static List <T> GetAllwithInclude <dbContext, T>() where dbContext : DbContext, new() where T : class, IbaseProperties, new() { #region to get list try { List <T> result = new List <T>(); var navs = withType.GetNaviProps <T>(); int n = navs.Length; using (dbContext sc = new dbContext()) { switch (n) { case 1: result = sc.Set <T>().Include(navs[0]).ToList(); break; case 2: result = sc.Set <T>() .Include(navs[0]) .Include(navs[1]) .ToList(); break; case 3: result = sc.Set <T>() .Include(navs[0]) .Include(navs[1]) .Include(navs[2]) .ToList(); break; case 4: result = sc.Set <T>() .Include(navs[0]) .Include(navs[1]) .Include(navs[2]) .Include(navs[3]) .ToList(); break; case 5: result = sc.Set <T>() .Include(navs[0]) .Include(navs[1]) .Include(navs[2]) .Include(navs[3]) .Include(navs[4]) .ToList(); break; default: result = sc.Set <T>().ToList(); break; } return(result); } } catch (Exception ex) { //MessageBox.Show(ex.Message); return(null); throw; } #endregion }
public async Task <IEnumerable <T> > GetAll() { return(await context.Set <T>().AsNoTracking().ToListAsync()); }
public TEntity Get(int Id) { return(Context.Set <TEntity>().Find(Id)); }