public void BeforeSave()
{
SaveMap = new Dictionary <Type, List <EntityInfo> >();
EntitiesWithAutoGeneratedKeys = new List <EntityInfo>();
EntityInfoGroups.ForEach(eg => {
var entityInfos = eg.EntityInfos.Where(ei => ContextProvider.BeforeSaveEntity(ei)).ToList();
EntitiesWithAutoGeneratedKeys.AddRange(entityInfos.Where(ei => ei.AutoGeneratedKey != null));
SaveMap.Add(eg.EntityType, entityInfos);
});
SaveMap = ContextProvider.BeforeSaveEntities(SaveMap);
}