Forgive me if my terminology is wrong. I have the following DataSet:
I have a master-detail page via drag and dropping from VS DataSources window which lets a user choose a specific build for which it shows the build details and also a further detail page of every SupplierComponent used in each build:
What I am wanting is for the DataGridView on the top right (BuildSupplierComponents by BuildID) to show details from the linked Supplier and Component tables (via the SupplierComponent table) rather than the ID of the entry in the SupplierComponent table.
I thought I could use Linq to perform the joins (essentially to a depth of 2?) and then set the Datasource of the top right DataGridView to the linq results. Thus I tried the following code:
Private Sub BuildBindingSource_CurrentChanged(sender As Object, e As EventArgs) Handles BuildBindingSource.CurrentChanged
If BuildBindingSource.Current Is Nothing Then Return
Dim BuildID As Integer = DirectCast(BuildBindingSource.Current.row, MainDataSet.BuildRow).ID
Dim var = From bsc In DirectCast(MainDS.Tables("BuildSupplierComponents"), MainDataSet.BuildSupplierComponentsDataTable)
Join sc In DirectCast(MainDS.Tables("SupplierComponent"), MainDataSet.SupplierComponentDataTable) On sc.ID Equals bsc.SupplierComponentID
Join s In DirectCast(MainDS.Tables("Supplier"), MainDataSet.SupplierDataTable) On s.ID Equals sc.SupplierID
Join c In DirectCast(MainDS.Tables("Component"), MainDataSet.ComponentDataTable) On c.ID Equals sc.ComponentID
Where bsc.BuildID = BuildID
Select New With {.Supplier = s.Name, .component = c.Name}
BuildSupplierComponentsBindingSource.DataSource = var
End Sub
However, this produces a null result, even when there is data in the BuildSupplierComponents.
Any ideas how I can achieve this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…