Exemplo n.º 1
0
        internal static IEnumerable <CommandBase> ComputeDelta(
            EntityName tableName,
            IEnumerable <MappingModel> currentMappings,
            IEnumerable <MappingModel> targetMappings)
        {
            var createdModels = DeltaHelper.GetCreated(
                currentMappings,
                targetMappings,
                m => (m.MappingName, m.MappingKind));
            var updatedModels = DeltaHelper.GetUpdated(
                currentMappings,
                targetMappings,
                m => (m.MappingName, m.MappingKind));
            var droppedModels = DeltaHelper.GetDropped(
                currentMappings,
                targetMappings,
                m => (m.MappingName, m.MappingKind));
            var createCommands = createdModels
                                 .Concat(updatedModels.Select(p => p.after))
                                 .Select(m => m.ToCreateMappingCommand(tableName));
            var dropCommands = droppedModels
                               .Select(m => m.ToDropMappingCommand(tableName));

            return(dropCommands
                   .Cast <CommandBase>()
                   .Concat(createCommands));
        }
        internal static IEnumerable <CommandBase> ComputeDelta(
            IImmutableList <CreateFunctionCommand> currentFunctionCommands,
            IImmutableList <CreateFunctionCommand> targetFunctionCommands)
        {
            var createdFunctions = DeltaHelper.GetCreated(
                currentFunctionCommands,
                targetFunctionCommands,
                c => c.FunctionName);
            var updatedFunctions = DeltaHelper.GetUpdated(
                currentFunctionCommands,
                targetFunctionCommands,
                c => c.FunctionName);
            var droppedFunctions = DeltaHelper.GetDropped(
                currentFunctionCommands,
                targetFunctionCommands,
                c => c.FunctionName);
            var createCommands = createdFunctions
                                 .Concat(updatedFunctions.Select(p => p.after));
            var dropCommands = droppedFunctions
                               .Select(c => new DropFunctionCommand(c.FunctionName));

            return(createCommands
                   .Cast <CommandBase>()
                   .Concat(dropCommands));
        }