Пример #1
0
        public void Update(HiFiveRecord item)
        {
            var itemToUpdate = _context.HiFiveRecords
                               .SingleOrDefault(hiFive => hiFive.HiFiver == item.HiFiver);

            if (itemToUpdate != null)
            {
                // update fields here

                _context.SaveChanges();
            }
        }
Пример #2
0
 public void AddOrUpdate(HiFiveRecord item)
 {
     // Old post, but AddOrUpdate should only be used
     // in migrations, according to this:
     // http://thedatafarm.com/data-access/take-care-with-ef-4-3-addorupdate-method/
     if (Find(item.HiFiver) == null)
     {
         _context.HiFiveRecords.Add(item);
     }
     else
     {
         Update(item);
     }
     _context.SaveChanges();
 }