示例#1
0
 public void Add(Client entity)
 {
     using (var dbContext = new PoREntities(ConnectionString))
     {
         dbContext.Clients.Add(entity);
         dbContext.SaveChanges();
     }
 }
示例#2
0
 public void Add(BookedItem entity)
 {
     using (var dbContext = new PoREntities(ConnectionString))
     {
         dbContext.BookedItems.Add(entity);
         dbContext.SaveChanges();
     }
 }
示例#3
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();
     }
 }
示例#4
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();
     }
 }