In the entity infrastructure, you must write a lot of code to save or update a single object:
using (DataContext context = new DataContext()) { context.Task.Attach(task); if (task.ID == 0) { context.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Added); } else { context.ApplyOriginalValues(task.GetType().Name, task); } context.SaveChanges(); }
in sleep mode it's just saveOrUpdate()
It's not about laziness, but about making it short and clean.
source share