コード例 #1
0
 public void Location_Update(Location item)
 {
     using (WorkSchedule context = new WorkSchedule())
     {
         context.Entry <Location>(context.Locations.Attach(item)).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #2
0
        [DataObjectMethod(DataObjectMethodType.Insert, false)] //let the user slect to slelect method
        public void Location_Add(Location item)
        {
            //input into this method at the instance level
            using (WorkSchedule context = new WorkSchedule())
            {
                //create a pointer variable for the instance type
                //set this pointer to null
                Location added = null;
                //setup the add request for the dbcontext
                added = context.Locations.Add(item);

                //saving the changes will cause the .Add to execute

                //commits the Add to database
                //evaluates the annotation (validation) on your entity
                context.SaveChanges();
            }
        }