Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use a list join on relationship in order to have the data in a particular order before doing any additional processes.

Here is what I have:

 Dim Relationship As List(Of String) = New List(Of String)() From {
            "Employee",
            "Spouse",
            "Partner",
            "Child"
        }

        Dim query As EnumerableRowCollection(Of DataRow) = From item In dt.AsEnumerable() Order By item.Field(Of Long)(sort_str), item.Field(Of String)("Relationship")., item.Field(Of String)("Relationship").StartsWith("Spouse"), item.Field(Of String)("Relationship").StartsWith("Child"), item.Field(Of String)("Last_name"), item.Field(Of String)("First_name") Select item
        Dim result = query.CopyToDataTable()
        Demographic_data_view.DataSource = result


However, the relationship portion of the code should be a join, but I can not seem to add a join in between the order by statements.

        'Dim query = From item In Relationship Join row In dt.AsEnumerable() On item Equals row.Field(Of String)("Relationship") Order By item.Field(Of String)(sort_str) Select row

Order by level of importance:
1. Individual ID
2. Relationship (Employee,Spouse,Partner,Child) in that order
3. Last_name
4. First_name


What I have tried:

I have researched for the past couple of days and originally tried to do a simple row order by with each fieled listed above. However, the data is not coming out right do to the order being wrong.
Posted
Updated 22-Nov-22 14:55pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900