Personally I think it is useless to build a dictionary with add/insert method delegates. It's a lot of repetitive code. The context has generic methods to insert or update any entity object. You can even make one method that does both, for example (based on ObjectContext):
public static void Upsert<T>(this ObjectContext context, T entity, int key)
where T : EntityObject
{
if (entity != null)
{
ObjectSet<T> objectSet = context.CreateObjectSet<T>();
if (key > 0)
{
if (entity.EntityState == EntityState.Detached)
{
objectSet.Attach(entity);
context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
}
}
else
{
objectSet.AddObject(entity);
}
}
}
If you want you can even factor out the key argument by getting the key field from the EF model and doing some reflection on the entity, but that probably slows down the process remarkably.
Note that an Attached persisted object is ignored by this method: it is assumed that it will be saved by the context it already belongs to.