public void Extract_ProjectSpecificCatalogue_FilterReference() { //make the catalogue a custom catalogue for this project CustomExtractableDataSet.Project_ID = _project.ID; CustomExtractableDataSet.SaveToDatabase(); var pipe = SetupPipeline(); pipe.Name = "Extract_ProjectSpecificCatalogue_FilterReference Pipe"; pipe.SaveToDatabase(); var rootContainer = new FilterContainer(DataExportRepository); _selectedDataSet.RootFilterContainer_ID = rootContainer.ID; _selectedDataSet.SaveToDatabase(); var filter = new DeployedExtractionFilter(DataExportRepository, "monkeys only", rootContainer); filter.WhereSQL = "SuperSecretThing = 'monkeys can all secretly fly'"; filter.SaveToDatabase(); rootContainer.AddChild(filter); //get rid of any lingering joins foreach (JoinInfo j in CatalogueRepository.GetAllObjects <JoinInfo>()) { j.DeleteInDatabase(); } //add the ability to join the two tables in the query var idCol = _extractableDataSet.Catalogue.GetAllExtractionInformation(ExtractionCategory.Core).Single(c => c.IsExtractionIdentifier).ColumnInfo; var otherIdCol = CustomCatalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific).Single(e => e.GetRuntimeName().Equals("PrivateID")).ColumnInfo; new JoinInfo(CatalogueRepository, idCol, otherIdCol, ExtractionJoinType.Left, null); new SelectedDataSetsForcedJoin(DataExportRepository, _selectedDataSet, CustomTableInfo); //generate a new request (this will include the newly created column) _request = new ExtractDatasetCommand(_configuration, new ExtractableDatasetBundle(_extractableDataSet)); var tbl = Database.ExpectTable("TestTable"); tbl.Truncate(); using (var blk = tbl.BeginBulkInsert()) { var dt = new DataTable(); dt.Columns.Add("PrivateID"); dt.Columns.Add("Name"); dt.Columns.Add("DateOfBirth"); dt.Rows.Add(new object[] { "Priv_12345", "Bob", "2001-01-01" }); dt.Rows.Add(new object[] { "Priv_wtf11", "Frank", "2001-10-29" }); blk.Upload(dt); } ExtractionPipelineUseCase useCase; IExecuteDatasetExtractionDestination results; Execute(out useCase, out results); var mainDataTableCsv = results.DirectoryPopulated.GetFiles().Single(f => f.Name.Equals("TestTable.csv")); Assert.IsNotNull(mainDataTableCsv); var lines = File.ReadAllLines(mainDataTableCsv.FullName); Assert.AreEqual("ReleaseID,Name,DateOfBirth", lines[0]); Assert.AreEqual("Pub_54321,Bob,2001-01-01", lines[1]); Assert.AreEqual(2, lines.Length); }