public virtual IEnumerable <ModificationCommand> GenerateModificationCommands([CanBeNull] IModel model)
        {
            Check.DebugAssert(
                Columns.Length == Values.GetLength(1),
                $"The number of values doesn't match the number of keys (${Columns.Length})");

            var table      = model?.GetRelationalModel().FindTable(Table, Schema);
            var properties = table != null
                ? MigrationsModelDiffer.GetMappedProperties(table, Columns)
                : null;

            for (var i = 0; i < Values.GetLength(0); i++)
            {
                var modifications = new ColumnModification[Columns.Length];
                for (var j = 0; j < Columns.Length; j++)
                {
                    modifications[j] = new ColumnModification(
                        Columns[j], originalValue: null, value: Values[i, j], property: properties?[j],
                        columnType: ColumnTypes?[j], isRead: false, isWrite: true, isKey: true, isCondition: false,
                        sensitiveLoggingEnabled: false);
                }

                yield return(new ModificationCommand(Table, Schema, modifications, sensitiveLoggingEnabled: false));
            }
        }
Esempio n. 2
0
        public virtual IEnumerable <ModificationCommand> GenerateModificationCommands(IModel?model)
        {
            Check.DebugAssert(
                KeyColumns.Length == KeyValues.GetLength(1),
                $"The number of key values doesn't match the number of keys (${KeyColumns.Length})");

            var table      = model?.GetRelationalModel().FindTable(Table, Schema);
            var properties = table != null
                ? MigrationsModelDiffer.GetMappedProperties(table, KeyColumns)
                : null;

            var modificationCommandFactory = new ModificationCommandFactory();

            for (var i = 0; i < KeyValues.GetLength(0); i++)
            {
                var modificationCommand = modificationCommandFactory.CreateModificationCommand(
                    new ModificationCommandParameters(
                        Table, Schema, sensitiveLoggingEnabled: false));
                for (var j = 0; j < KeyColumns.Length; j++)
                {
                    var columnModificationParameters = new ColumnModificationParameters(
                        KeyColumns[j], originalValue: null, value: KeyValues[i, j], property: properties?[j],
                        columnType: KeyColumnTypes?[j], typeMapping: null, read: false, write: true, key: true, condition: true,
                        sensitiveLoggingEnabled: false);

                    modificationCommand.AddColumnModification(columnModificationParameters);
                }

                yield return((ModificationCommand)modificationCommand);
            }
        }