BeforeSaveEntity() 보호된 메소드

The method is called for each entity to be saved before the save occurs. If this method returns 'false' then the entity will be excluded from the save. The base implementation returns the result of BeforeSaveEntityDelegate, or 'true' if BeforeSaveEntityDelegate is null.
protected BeforeSaveEntity ( EntityInfo entityInfo ) : bool
entityInfo EntityInfo
리턴 bool
예제 #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();
        }