Example #1
0
        /// <summary>
        /// Performs multiple updates in a single transaction, with disparate (but presumably related) data.
        /// </summary>
        /// <param name="dataSet1">first data set</param>
        /// <param name="dataSet2">second data set</param>
        public void UpdateMultipleDetails(CustomDataSet dataSet1, SpecialDataSet dataSet2)
        {
            // Prepare the connection
            IDbConnection connection = new System.Data.SqlClient.SqlConnection(/* Connection string goes here*/);

            Library.TransactionWrapper transactionWrapper = new Library.TransactionWrapper(connection);

            // Hook data for first operation
            CustomDataUpdate             customDataUpdate = new CustomDataUpdate(this.log);
            CustomTransactionedOperation operation1       = new CustomTransactionedOperation(dataSet1);

            operation1.Execute += new Library.TransactionedOperationDelegate(customDataUpdate.UpdateData);

            // Hook data for second operation
            AggregateTransactionedOperation operation2 = new AggregateTransactionedOperation(dataSet2);

            operation2.Execute += new Library.TransactionedOperationDelegate(AggregateTransactionedOperation.SelfContainedUpdateData);

            // Collect together the operations and make them atomic
            Library.TransactionedOperation[] operations = new Library.TransactionedOperation[] { operation1, operation2 };
            transactionWrapper.MakeAtomic(operations);
        }
Example #2
0
 public AggregateTransactionedOperation(SpecialDataSet dataSet)
 {
     this.Example = dataSet.MoreExampleData;
 }