Example #1
0
 public void Update(BookedItem entity)
 {
     using (var dbContext = new PoREntities(ConnectionString))
     {
         // We could turn this into an upsert
         dbContext.BookedItems.Attach(entity);
         dbContext.Entry(entity).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Example #2
0
 public void Update(Item entity)
 {
     using (var dbContext = new PoREntities(ConnectionString))
     {
         // We could turn this into an upsert
         dbContext.Items.Attach(entity);
         dbContext.Entry(entity).State = EntityState.Modified;
         // This Could cause problems.  You could approach this like and upsert and do something like
         //   AddOrUpdate(i=> i.id == entity.Id).  Additionally you may want to set certain properties
         //   of the entity to 'not modified' if they're null so as not to update the DB.
         dbContext.SaveChanges();
     }
 }