/// <summary> /// /// </summary> /// <param name="entity"></param> public void AddEntity(TEntity entity) { DataContext.AddObject(entity); if (SaveChangesAutomatically) { DataContext.SaveChanges(); } }
protected void InsertObject(T entity, bool commit) { DataContext.AddObject(EntitySetName, entity); try { if (commit) { DataContext.SaveChanges(); } } catch (Exception e) { //Need to restore back the original data in the client side if DataContext.DataContext.SaveChanges() fails; otherwise, next time, these bad data is still here DataContext.DeleteObject(entity); Log.Error(e); throw; } }