I am having a problem binding data from a child entity object of a joined/normalized table (object)  in my entity model. If I want to display a grand child column rows, I get only a first item.

Alternatively, I can get a list of rows of my normalized-joined objects.

 

I have following table structure CASE- parent, MEM_CASE – child, MEM- grandchild table.

CASE as a parent table has one-to-many relationship to MEM_CASE table; MEM_CASE table has many-to-one relationship to MEM table.

CASE table has following properties related to these tables:

Scalar: CASEID

Navigation: MEM_CASE

MEM_CASE table has following properties:

Scalar: MEM_CASEID

Navigation:       MEM table

                        CASE table

MEM table has following props:

Scalar: MEMID

            fullname

Navigation: MEM_CASE

 

I want to have a list of fullname column in either listbox or combo box, but I can only get the first item (first selected item).  I can also get a list of MEM_CASE objects, but not the list of fullname columns. I can have multiple fullname rows as a result.

Following bindings does not work:

Me.ListBox1.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.MEM_CASEBindingSource, "MEM.fullname", True))

Nor:

Me.ListBox1.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me CASEBindingSource., "MEM_CASE.MEM.fullname", True))

Nor, following from code behind:

Me.ListBox1.DataSource = CType(CType(Me.BindingContext(CASEBindingSource, "MEM_CASE"), BindingManagerBase), CurrencyManager).List

Me.ListBox1.DisplayMember = "MEM.fullname"

 

Other than my workaround down, is there any way of reaching properties of a child object from normalized - joined tables in relationship many to many?

 

I have a workaround where I create a new list of object type myproxy.MEM, then I loop through the list of items of MEM_CASE objects which are of type MEM object, and add items to my new list. Now I have a new list of type MEM instead of list of MEM_CASE and I am able to bind to this new list. The code looks like:

  

        Dim memList As New List(Of MyDataServiceProxy.MEM)

        For i = 0 To CASEBindingSource.GetRelatedCurrencyManager("MEM_CASE").List.Count - 1

            'fill new MEM list from MEM_CASE:           
             memList.Add(CType(CASEBindingSource.GetRelatedCurrencyManager("MEM_CASE").List(i), MyWebDataServiceProxy.MEM_CASE).MEM)

        Next

        'bind new list to our control to display a column/property of MEM object:

        Me.ListBox1.DataSource = memList

        Me.ListBox1.DisplayMember = "fullname"