コード例 #1
0
        public void SpecialEvents_Delete(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //lookup the instance and record if found

                SpecialEvent existing = context.SpecialEvents.Find(item.EventCode);
                //setup command to execute the delete
                context.SpecialEvents.Remove(existing);
                //command is not executed untill it is actually saved
                context.SaveChanges();
            }
        }
コード例 #2
0
        public void SpecialEvents_Update(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //Indicate the updating item instance
                //alter the modified status flag for this instance

                context.Entry<SpecialEvent>(context.SpecialEvents.Attach(item)).State = System.Data.Entity.EntityState.Modified;
                //command is not executed untill it is actually saved
                context.SaveChanges();
            }
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: swu18/InClassDemo
        public void SpecialEvent_Delete(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {

                // indicate the updateing item instance
                //alter the Modified Status flag for this instance
                SpecialEvent existing = context.SpecialEvents.Find(item.EventCode);
                // set up the command to execute the delete
                context.SpecialEvents.Remove(existing);
                //command is not executed until it it actually saved.
                context.SaveChanges();
            }
        }
コード例 #4
0
        public void SpecialEvents_Add(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
             //these methods are execute using an instance level item

            //Set up a instance pointer and intialize to null
            SpecialEvent added = null;
            //setup the command to execute the add
            added = context.SpecialEvents.Add(item);
             //command is not executed untill it is actually saved
            context.SaveChanges();
            }
        }
コード例 #5
0
 public void SpecialEvents_Delete(SpecialEvent item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         //look the item instance on the database to determine if it exists
         //on the delete ensure you reference the P-Key
         SpecialEvent existing = context.SpecialEvents.Find(item.EventCode);
         //set up the data request command
         context.SpecialEvents.Remove(existing);
         //commit the action to happen
         context.SaveChanges();
     }
 }
コード例 #6
0
        public void SpecialEvents_Update(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
            context.Entry<SpecialEvent>(context.SpecialEvents.Attach(item)).State = System.Data.Entity.EntityState.Modified;

            context.SaveChanges();

            }
        }
コード例 #7
0
        public void SpecialEvents_Add(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //create a pointer variable for the instance type
                //set this pointer to null
                SpecialEvent added = null;

                //set up the add request for the dbcontext
                added = context.SpecialEvents.Add(item);

                //saving the changes will cause the .Add to execute
                //commits the add to the database
                //evaluates the annotations (validation) on your entity
                context.SaveChanges();

            }
        }
コード例 #8
0
ファイル: AdminController.cs プロジェクト: xdu3/InClassDemo
        public void SpecialEvent_Delete(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                SpecialEvent existing = context.SpecialEvents.Find(item.EventCode);
                context.SpecialEvents.Remove(existing);

                context.SaveChanges();
            }
        }
コード例 #9
0
ファイル: AdminController.cs プロジェクト: xdu3/InClassDemo
 public void SpecialEvent_Add(SpecialEvent item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         SpecialEvent added = null;
         added = context.SpecialEvents.Add(item);
         //comment is not used until it is actully save
         context.SaveChanges();
     }
 }
コード例 #10
0
        public void SpecialEvent_Delete(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //lookup the item instance to determine if the instance exists
                SpecialEvent existing = context.SpecialEvents.Find(item.EventCode);
                //setup the delete request command
                context.SpecialEvents.Remove(existing);
                //commit the action to happen.
                context.SaveChanges();

            }
        }
コード例 #11
0
        public void SpecialEvents_Add(SpecialEvent item)
        {
            //input into this method is at the instance level
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //create a pointer variable for the instance type.
                //Set this pointer to null.
                SpecialEvent added = null;

                //Set up the add request for the dbcontext
                added = context.SpecialEvents.Add(item);

                //Saving the changes will cause the .Add to execute (delayed execution)
                //Commits the add to the database
                //Evaluates the annotations (validation) on your entity
                context.SaveChanges();
            }
        }