public void UpdateAuto(Auto modified, Auto original) { using (var context = new AutoReservationEntities()) { try { context.Autos.Attach(original); context.Autos.ApplyCurrentValues(modified); context.SaveChanges(); } catch (OptimisticConcurrencyException) { modified.EntityKey = original.EntityKey; context.Refresh(RefreshMode.StoreWins, modified); context.SaveChanges(); throw new LocalOptimisticConcurrencyException <Auto>( "Konflikt beim Ă„ndern eines Wertes der Klasse Auto") { Entity = modified }; } } }
public void UpdateReservation(Reservation modified, Reservation original) { using (var context = new AutoReservationEntities()) { try { context.Reservationen.Attach(original); context.Reservationen.ApplyCurrentValues(modified); context.SaveChanges(); } catch (OptimisticConcurrencyException) { modified.EntityKey = original.EntityKey; context.Refresh(RefreshMode.StoreWins, modified); context.SaveChanges(); throw new LocalOptimisticConcurrencyException <Reservation>("Update Reservation: Concurrency-Fehler") { Entity = modified }; } } }