BeforeSaveEntities() защищенный Метод

Called after BeforeSaveEntity, and before saving the entities to the persistence layer. Allows adding, changing, and removing entities prior to save. The base implementation returns the result of BeforeSaveEntitiesDelegate, or the unchanged saveMap if BeforeSaveEntitiesDelegate is null.
protected BeforeSaveEntities ( Dictionary saveMap ) : List>.Dictionary
saveMap Dictionary A List of EntityInfo for each Type
Результат List>.Dictionary
Пример #1
0
 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);
 }
 public void BeforeSave()
 {
     SaveMap = new Dictionary <Type, List <EntityInfo> >();
     EntityInfoGroups.ForEach(eg => {
         var entityInfos = eg.EntityInfos.Where(ei => ContextProvider.BeforeSaveEntity(ei)).ToList();
         SaveMap.Add(eg.EntityType, entityInfos);
     });
     SaveMap = ContextProvider.BeforeSaveEntities(SaveMap);
     EntitiesWithAutoGeneratedKeys = SaveMap
                                     .SelectMany(eiGrp => eiGrp.Value)
                                     .Where(ei => ei.AutoGeneratedKey != null && ei.EntityState != EntityState.Detached)
                                     .ToList();
 }
Пример #3
0
        public async Task BeforeSaveAsync(CancellationToken cancellationToken)
        {
            SaveMap = new Dictionary <Type, List <EntityInfo> >();
            foreach (var eg in EntityInfoGroups)
            {
                var entityInfos = new List <EntityInfo>();
                foreach (var ei in eg.EntityInfos)
                {
                    if (ContextProvider.BeforeSaveEntity(ei) && await ContextProvider.BeforeSaveEntityAsync(ei, cancellationToken))
                    {
                        entityInfos.Add(ei);
                    }
                }
                SaveMap.Add(eg.EntityType, entityInfos);
            }
            SaveMap = await ContextProvider.BeforeSaveEntitiesAsync(ContextProvider.BeforeSaveEntities(SaveMap), cancellationToken);

            EntitiesWithAutoGeneratedKeys = SaveMap
                                            .SelectMany(eiGrp => eiGrp.Value)
                                            .Where(ei => ei.AutoGeneratedKey != null && ei.EntityState != EntityState.Detached)
                                            .ToList();
        }