troubleshooting Question

Help with my LINQ query

Avatar of Philippe Renaud
Philippe RenaudFlag for Canada asked on
.NET ProgrammingC#Visual Basic.NET
19 Comments1 Solution352 ViewsLast Modified:
Hello EE,

I have this LINQ that works well :

        Dim q = (From m In myTableValue _
                 Select New With _
                 { _
                    .Key = m.Field(Of String)(bound.Rows(0)("Link_Table_Column_Name").ToString()).ToString(), _
                    .Value = m.Field(Of String)(bound.Rows(0)("Link_Table_Column_Name").ToString()) _
                 }).GroupBy(Function(p) p.Key).Select(Function(g) g.First()).ToList()

myTableValue is a DataTable.
My problem is that, the .Key and .Value gets a value but from now on, depending on another DataTable Results I might need to do this:

.Key = m.Field(Of String)(bound.Rows(0)("Link_Table_Column_Name").ToString()).ToString() + "-" + m.Field(Of String)(bound.Rows(1)("Link_Table_Column_Name").ToString()).ToString()

you See ? its dynamical. sometimes the key gets only 1 value lets say  "01"  but sometimes It might be "01-02"

it might even go as far as 3 values. (with 2 dashes)

How can I construct my Linq statement depending on the other dataTable results dynamically?  Can you help me ? I hope everything is understandable.
Join our community to see this answer!
Unlock 1 Answer and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros