public Customer Update(Customer customerUpdate)
        {
            var customerEntry = _ctx.Update(customerUpdate);

            _ctx.SaveChanges();
            return(customerEntry.Entity);
        }
        public Address Update(Address address)
        {
            var entry = _ctx.Update(address);

            _ctx.SaveChanges();
            return(entry.Entity);
        }
예제 #3
0
        public City Update(City cityToUpdate)
        {
            // 1: Get rid of all current rows with CityId 7002
            _ctx.CityTourists.RemoveRange(_ctx.CityTourists.Where(ct => ct.CityId == cityToUpdate.ZipCode));
            // 2: Adding All new Relations to CityTourist
            _ctx.CityTourists.AddRange(cityToUpdate.TouristsVisits.Select(t =>
                                                                          new CityTouristSql()
            {
                CityId = cityToUpdate.ZipCode, TouristId = t.Tourist.Id, VisitDate = t.VisitTime
            }));
            // 3: Saving updates
            var entry = _ctx.Update(cityToUpdate);

            _ctx.SaveChanges();
            return(entry.Entity);
        }