Esempio n. 1
0
        // GET: api/Heroes
        public async Task <IHttpActionResult> Get()
        {
            List <HeroInfo> result = new List <HeroInfo>();

            using (HeroDbContext context = new HeroDbContext())
            {
                var heroes = await context.Heroes.Where(h => true).ToListAsync();

                foreach (Hero hero in heroes)
                {
                    await context.Entry(hero).Collection(h => h.PowerDetails).LoadAsync();

                    result.Add(new HeroInfo(hero));
                }
            }

            return(Json(result));
        }
Esempio n. 2
0
        public void Update(T entity)
        {
            _context.Entry(entity).State = EntityState.Modified;

            Save();
        }