Ejemplo n.º 1
0
        /// <summary>
        ///     Generates the commands that correspond to this operation.
        /// </summary>
        /// <returns> The commands that correspond to this operation. </returns>
        public virtual IEnumerable <ModificationCommand> GenerateModificationCommands([CanBeNull] IModel model)
        {
            Debug.Assert(KeyColumns.Length == KeyValues.GetLength(1),
                         $"The number of key values doesn't match the number of keys (${KeyColumns.Length})");
            Debug.Assert(Columns.Length == Values.GetLength(1),
                         $"The number of values doesn't match the number of keys (${Columns.Length})");
            Debug.Assert(KeyValues.GetLength(0) == Values.GetLength(0),
                         $"The number of key values doesn't match the number of values (${KeyValues.GetLength(0)})");

            var properties = model != null
                ? TableMapping.GetTableMapping(model, Table, Schema)?.GetPropertyMap()
                : null;

            for (var i = 0; i < KeyValues.GetLength(0); i++)
            {
                var keys = new ColumnModification[KeyColumns.Length];
                for (var j = 0; j < KeyColumns.Length; j++)
                {
                    keys[j] = new ColumnModification(
                        KeyColumns[j], originalValue: null, value: KeyValues[i, j], property: properties?.Find(KeyColumns[j]),
                        isRead: false, isWrite: false, isKey: true, isCondition: true);
                }

                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?.Find(Columns[j]),
                        isRead: false, isWrite: true, isKey: true, isCondition: false);
                }

                yield return(new ModificationCommand(Table, Schema, keys.Concat(modifications).ToArray()));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Generates the commands that correspond to this operation.
        /// </summary>
        /// <returns> The commands that correspond to this operation. </returns>
        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 properties = model != null
                ? TableMapping.GetTableMapping(model, Table, Schema)?.GetPropertyMap()
                : 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?.Find(Columns[j]),
                        isRead: false, isWrite: true, isKey: true, isCondition: false, sensitiveLoggingEnabled: true);
                }

                yield return(new ModificationCommand(Table, Schema, modifications, sensitiveLoggingEnabled: true));
            }
        }