コード例 #1
0
        public void AddNewLocation(Location item)
        {
            using (var context = new WorkScheduleContext())
            {
                // Get the new stuff
                var added = context.Locations.Add(item);

                context.SaveChanges();
            }
        }
コード例 #2
0
        public void UpdateLocation(Location item)
        {
            using (var context = new WorkScheduleContext())
            {
                // Edit current location
                var attached = context.Locations.Attach(item);

                var existing = context.Entry<Location>(attached);

                existing.State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();
            }
        }