Dapper.SimpleSave.Impl.UpdateCommand.AddOperation C# (CSharp) Méthode

AddOperation() public méthode

public AddOperation ( UpdateOperation operation ) : void
operation UpdateOperation
Résultat void
        public void AddOperation(UpdateOperation operation)
        {
            var name = TableName;
            if (null != name && operation.TableName != name)
            {
                throw new ArgumentException(string.Format(
                    "Table name mismatch for UPDATE command. Expected: {0}. Actual: {1}.",
                    name,
                    operation.TableName),
                    "operation");
            }

            var pk = PrimaryKeyAsObject;
            if (null != pk
                && !PrimaryKeyComparer.SuppliedPrimaryKeyValuesMatch(
                    operation.OwnerMetadata,
                    pk,
                    operation.OwnerPrimaryKeyAsObject))//operation.OwnerPrimaryKey != pk.Value)
            {
                throw new ArgumentException(string.Format(
                    "Primary key mismatch for UPDATE command on table {0}. Expected: {1}. Actual: {2}.",
                    name,
                    pk,
                    operation.OwnerPrimaryKeyAsObject),
                    "operation");
            }

            name = PrimaryKeyColumn;
            if (null != name && operation.OwnerPrimaryKeyColumn != name)
            {
                throw new ArgumentException(string.Format(
                    "Primary key column mismatch for UPDATE command on table {0}. Expected: {1}. Actual: {2}.",
                    TableName,
                    name,
                    operation.OwnerPrimaryKeyColumn),
                    "operation");
            }

            TableName = operation.TableName;
            PrimaryKeyColumn = operation.OwnerPrimaryKeyColumn;

            _operations.Add(operation);
        }

Usage Example

Exemple #1
0
        private void ApplyUpdatesSoFarAsNewCommand(
            IList <BaseCommand> results,
            IList <UpdateOperation> updates,
            ref string updateTableName,
            ref object updatePk)
        {
            if (updates.Count == 0)
            {
                return;
            }
            var command = new UpdateCommand();

            updates.ForEach(update => command.AddOperation(update));
            results.Add(command);
            updates.Clear();
            updateTableName = null;
            updatePk        = null;
        }
All Usage Examples Of Dapper.SimpleSave.Impl.UpdateCommand::AddOperation
UpdateCommand