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(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); context.SpecialEvents.Remove(existing); context.SaveChanges(); } }
public void SpecialEvents_Add(SpecialEvent item) { using(eRestaurantContext context = new eRestaurantContext()) { SpecialEvent added = null; added = context.SpecialEvents.Add(item); context.SaveChanges(); //Commits the add to the database. //Furthermore, this evaluates the annotations (validates) on the entity. //Included: [Required], [StringLength], [Range], etc. } }
public void SpecialEvents_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent added = null; added = context.SpecialEvents.Add(item); // commits the add to the database // evaluates the annotations (validations) on your entity // [Required],[StringLength],[Range],... context.SaveChanges(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //look up the item instance on the database to determine if the instance exists //On delete make sutre u reference the PK SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //set up the delete request command context.SpecialEvents.Remove(existing); //commit the action to happen context.SaveChanges(); } }
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 //commits the add to the database //evaluates the annotations(validation) on your entity context.SaveChanges(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //look th eitem instance on th edatabase to detemine if the insatnce exist //on the delete make sure u have PK name SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //set up the data command request existing = context.SpecialEvents.Remove(existing); //commit the action to happen context.SaveChanges(); } }
public void SpecialEvent_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //look the item instance on the databse to detemine if the instance exists //on the delete ensure your reference the Primary Key SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //set up the delete request command context.SpecialEvents.Remove(existing); //commit the action to happen context.SaveChanges(); } }