예제 #1
0
        public void OneTransactionAndParallelWritingWithMARS()
        {
            //Arrange
            TwoColumnsTableFixture s2c = new TwoColumnsTableFixture(SqlConnection, "TransactionSourceParallelWrite");

            s2c.InsertTestData();
            TwoColumnsTableFixture d2c1   = new TwoColumnsTableFixture(SqlConnection, "TransactionDest1");
            TwoColumnsTableFixture d2c2   = new TwoColumnsTableFixture(SqlConnection, "TransactionDest2");
            DbSource <MySimpleRow> source = new DbSource <MySimpleRow>(SqlConnection, "TransactionSourceParallelWrite");

            string constring = $"{Config.SqlConnection.RawConnectionString("DataFlow")};MultipleActiveResultSets=True;";
            var    marscon   = new SqlConnectionManager(constring);
            DbDestination <MySimpleRow> dest1     = new DbDestination <MySimpleRow>(marscon, "TransactionDest1", batchSize: 2);
            DbDestination <MySimpleRow> dest2     = new DbDestination <MySimpleRow>(marscon, "TransactionDest2", batchSize: 2);
            Multicast <MySimpleRow>     multicast = new Multicast <MySimpleRow>();

            //Act & Assert
            marscon.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
            source.LinkTo(multicast);
            multicast.LinkTo(dest1);
            multicast.LinkTo(dest2);

            source.Execute();
            dest1.Wait();
            dest2.Wait();
            marscon.CommitTransaction();

            d2c1.AssertTestData();
            d2c1.AssertTestData();
        }