public MyOutputDataRow TestTransformationFunc(MyInputDataRow myRow) { MyOutputDataRow output = new MyOutputDataRow() { Value1 = myRow.Value1, LookupValue2 = LookupData.Where(ld => ld.Key == myRow.Value2).Select(ld => ld.LookupValue).FirstOrDefault() }; return(output); }
public void SimpleLookupFromDB(IConnectionManager connection) { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(connection, "Source"); source2Columns.InsertTestData(); FourColumnsTableFixture dest4Columns = new FourColumnsTableFixture(connection, "Destination"); FourColumnsTableFixture lookup4Columns = new FourColumnsTableFixture(connection, "Lookup"); lookup4Columns.InsertTestData(); DBSource <MyInputDataRow> source = new DBSource <MyInputDataRow>(connection, "Source"); DBSource <MyLookupRow> lookupSource = new DBSource <MyLookupRow>(connection, "Lookup"); //Act List <MyLookupRow> LookupTableData = new List <MyLookupRow>(); Lookup <MyInputDataRow, MyOutputDataRow, MyLookupRow> lookup = new Lookup <MyInputDataRow, MyOutputDataRow, MyLookupRow>( row => { MyOutputDataRow output = new MyOutputDataRow() { Col1 = row.Col1, Col2 = row.Col2, Col3 = LookupTableData.Where(ld => ld.Key == row.Col1).Select(ld => ld.LookupValue1).FirstOrDefault(), Col4 = LookupTableData.Where(ld => ld.Key == row.Col1).Select(ld => ld.LookupValue2).FirstOrDefault(), }; return(output); } , lookupSource , LookupTableData ); DBDestination <MyOutputDataRow> dest = new DBDestination <MyOutputDataRow>(connection, "Destination"); source.LinkTo(lookup); lookup.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest4Columns.AssertTestData(); }