Esempio n. 1
0
 public void Update(TEntity obj, bool saveChanges = true)
 {
     dbContext.Set <TEntity>().Update(obj);
     if (saveChanges)
     {
         dbContext.SaveChanges();
     }
 }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
 public IQueryable <Hero> Get()
 {
     return(_dbContext.Set <Hero>().AsQueryable());
 }
Esempio n. 4
0
 public GenericRepository(HeroDbContext context)
 {
     Context        = context;
     DbSet          = context.Set <TEntity>();
     DatabaseFacade = context.Database;
 }
Esempio n. 5
0
 public IEnumerable <T> GetAll()
 {
     return(_context.Set <T>());
 }