public void Update(TEntity obj, bool saveChanges = true) { dbContext.Set <TEntity>().Update(obj); if (saveChanges) { dbContext.SaveChanges(); } }
public void CreateHero(HeroInfo heroInfo) { using (var context = new HeroDbContext(_nameOrConnectionString)) { var hero = new Hero(heroInfo.Id, heroInfo.SerialNumber, heroInfo.Name, heroInfo.Power, heroInfo.AlterEgo); context.Set<Hero>().Add(hero); context.SaveChanges(); } }
public IQueryable <Hero> Get() { return(_dbContext.Set <Hero>().AsQueryable()); }
public GenericRepository(HeroDbContext context) { Context = context; DbSet = context.Set <TEntity>(); DatabaseFacade = context.Database; }
public IEnumerable <T> GetAll() { return(_context.Set <T>()); }