public void MergeJoinUsingOneObject() { //Arrange TwoColumnsTableFixture source1Table = new TwoColumnsTableFixture("MergeJoinDynamicSource1"); source1Table.InsertTestData(); TwoColumnsTableFixture source2Table = new TwoColumnsTableFixture("MergeJoinDynamicSource2"); source2Table.InsertTestDataSet2(); TwoColumnsTableFixture destTable = new TwoColumnsTableFixture("MergeJoinDynamicDestination"); DbSource <ExpandoObject> source1 = new DbSource <ExpandoObject>(Connection, "MergeJoinDynamicSource1"); DbSource <ExpandoObject> source2 = new DbSource <ExpandoObject>(Connection, "MergeJoinDynamicSource2"); DbDestination <ExpandoObject> dest = new DbDestination <ExpandoObject>(Connection, "MergeJoinDynamicDestination"); //Act MergeJoin <ExpandoObject> join = new MergeJoin <ExpandoObject>( (inputRow1, inputRow2) => { dynamic ir1 = inputRow1 as ExpandoObject; dynamic ir2 = inputRow2 as ExpandoObject; ir1.Col1 = ir1.Col1 + ir2.Col1; ir1.Col2 = ir1.Col2 + ir2.Col2; return(inputRow1); }); source1.LinkTo(join.Target1); source2.LinkTo(join.Target2); join.LinkTo(dest); source1.Execute(); source2.Execute(); dest.Wait(); //Assert Assert.Equal(3, RowCountTask.Count(Connection, "MergeJoinDynamicDestination")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDynamicDestination", "Col1 = 5 AND Col2='Test1Test4'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDynamicDestination", "Col1 = 7 AND Col2='Test2Test5'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDynamicDestination", "Col1 = 9 AND Col2='Test3Test6'")); }
public void MergeJoinUsingOneObject() { //Arrange TwoColumnsTableFixture source1Table = new TwoColumnsTableFixture("MergeJoinNonGenericSource1"); source1Table.InsertTestData(); TwoColumnsTableFixture source2Table = new TwoColumnsTableFixture("MergeJoinNonGenericSource2"); source2Table.InsertTestDataSet2(); TwoColumnsTableFixture destTable = new TwoColumnsTableFixture("MergeJoinNonGenericDestination"); DbSource <string[]> source1 = new DbSource <string[]>(Connection, "MergeJoinNonGenericSource1"); DbSource <string[]> source2 = new DbSource <string[]>(Connection, "MergeJoinNonGenericSource2"); DbDestination <string[]> dest = new DbDestination <string[]>(Connection, "MergeJoinNonGenericDestination"); //Act MergeJoin <string[]> join = new MergeJoin <string[]>( (inputRow1, inputRow2) => { inputRow1[0] = (int.Parse(inputRow1[0]) + int.Parse(inputRow2[0])).ToString(); inputRow1[1] += inputRow2[1]; return(inputRow1); }); source1.LinkTo(join.Target1); source2.LinkTo(join.Target2); join.LinkTo(dest); source1.Execute(); source2.Execute(); dest.Wait(); //Assert Assert.Equal(3, RowCountTask.Count(Connection, "MergeJoinNonGenericDestination")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinNonGenericDestination", "Col1 = 5 AND Col2='Test1Test4'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinNonGenericDestination", "Col1 = 7 AND Col2='Test2Test5'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinNonGenericDestination", "Col1 = 9 AND Col2='Test3Test6'")); }
public void DB_MergeJoin_DB() { TableDefinition source1TableDefinition = CreateTableForInput1("test.Source1"); TableDefinition source2TableDefinition = CreateTableForInput2("test.Source2"); TableDefinition destTableDefinition = CreateTableForDestination("test.Destination"); DBSource <MyDataRow1> source1 = new DBSource <MyDataRow1>() { SourceTableDefinition = source1TableDefinition }; DBSource <MyDataRow2> source2 = new DBSource <MyDataRow2>() { SourceTableDefinition = source2TableDefinition }; MergeJoin <MyDataRow1, MyDataRow2, MyDataRow1> join = new MergeJoin <MyDataRow1, MyDataRow2, MyDataRow1>( (input1, input2) => { input1.Col2 += input2.Col3; return(input1); }); DBDestination <MyDataRow1> dest = new DBDestination <MyDataRow1>() { DestinationTableDefinition = destTableDefinition }; source1.LinkTo(join.Target1); source2.LinkTo(join.Target2); join.LinkTo(dest); source1.Execute(); source2.Execute(); dest.Wait(); Assert.AreEqual(3, RowCountTask.Count("test.Destination", "Col2 in (11,102,1003)")); }
public void MergeJoinUsingOneObject() { //Arrange TwoColumnsTableFixture source1Table = new TwoColumnsTableFixture("MergeJoinSource1"); source1Table.InsertTestData(); TwoColumnsTableFixture source2Table = new TwoColumnsTableFixture("MergeJoinSource2"); source2Table.InsertTestDataSet2(); TwoColumnsTableFixture destTable = new TwoColumnsTableFixture("MergeJoinDestination"); DBSource <MySimpleRow> source1 = new DBSource <MySimpleRow>(Connection, "MergeJoinSource1"); DBSource <MySimpleRow> source2 = new DBSource <MySimpleRow>(Connection, "MergeJoinSource2"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(Connection, "MergeJoinDestination"); //Act MergeJoin <MySimpleRow, MySimpleRow, MySimpleRow> join = new MergeJoin <MySimpleRow, MySimpleRow, MySimpleRow>( (inputRow1, inputRow2) => { inputRow1.Col1 += inputRow2.Col1; inputRow1.Col2 += inputRow2.Col2; return(inputRow1); }); source1.LinkTo(join.Target1); source2.LinkTo(join.Target2); join.LinkTo(dest); source1.Execute(); source2.Execute(); dest.Wait(); //Assert Assert.Equal(3, RowCountTask.Count(Connection, "MergeJoinDestination")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDestination", "Col1 = 5 AND Col2='Test1Test4'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDestination", "Col1 = 7 AND Col2='Test2Test5'")); Assert.Equal(1, RowCountTask.Count(Connection, "MergeJoinDestination", "Col1 = 9 AND Col2='Test3Test6'")); }