private List <TEntity> GetSorted <TEntity>(IEnumerable <TEntity> entities) where TEntity : IEntity
        {
            var entitiesCopy = new List <TEntity>(entities);
            var mapper       = _persistenceMappings.GetMapping(typeof(TEntity));
            var dependencies = entitiesCopy.SelectMany(x => mapper.GetDependencies(x).Select(y => new Tuple <Guid, Guid>(y, x.ID)));
            var ids          = entitiesCopy.Select(x => x.ID).ToList();

            Graph.TopologicalSort(ids, dependencies);
            Graph.SortByGivenOrder(entitiesCopy, ids, plugin => plugin.ID);
            return(entitiesCopy);
        }
示例#2
0
 private void AppendCommand(PersistenceStorageCommand command, List <DbParameter> commandParameters, StringBuilder commandTextBuilder)
 {
     if (command.CommandType == PersistenceStorageCommandType.Insert)
     {
         AppendInsertCommand(commandParameters, commandTextBuilder, command.Entity, _persistenceMappingConfiguration.GetMapping(command.EntityType));
     }
     if (command.CommandType == PersistenceStorageCommandType.Update)
     {
         AppendUpdateCommand(commandParameters, commandTextBuilder, command.Entity, _persistenceMappingConfiguration.GetMapping(command.EntityType));
     }
     if (command.CommandType == PersistenceStorageCommandType.Delete)
     {
         AppendDeleteCommand(commandTextBuilder, command.Entity, _persistenceMappingConfiguration.GetMapping(command.EntityType));
     }
 }