Error Type Expected on LINQ Query

Hello EE,

Im trying to do this linq query :


            Dim qx = (From m In MyItems
                         Where arrString.All(Function(v) m.Value.Contains(v))
                         Let row = rowID
                         Let myKey = m.Key
                         Let myValue = m.Value
                     ).OrderBy(Function(n) n.myKey) _
                      .Select(Function(t) New With {t.row, t.myKey, t.myValue})

Open in new window



it does not stops while running my software, but if I place a breakpoint, and I try to see whats inside "qx", it says : Error Type expected"

the goal is to return 3 variables, (Row, myKey, myValue),  thats why I cannot do  .ToDictionnary() or .ToList()  I thought I needed to do Select New With since I have more than 2 varaibles

also I wanted to OrderBy in my LINQ
do you see any problem looking at it ?
LVL 1
PhilippeRenaudAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PhilippeRenaudAuthor Commented:
i think I fixed it myself,


this seems to work :

            Dim qx = (From m In MyItems
                      Where arrString.All(Function(v) m.Value.Contains(v))
                      Order By m.Key
                      Select New With
                      {
                        Key .Key = m.Key,
                        Key .Value = m.Value
                      }).AsEnumerable().Select(Function(k, i) New With {.Key = k.Key, .Value = k.Value, .Rank = i + 1}).ToList()

Open in new window

Miguel OzSenior Software EngineerCommented:
There is no need for the first select, this should work as well:
 Dim qx = (From m In MyItems
                      Where arrString.All(Function(v) m.Value.Contains(v))
                      Order By m.Key
                      ).Select(Function(k, i) New With {.Key = k.Key, .Value = k.Value, .Rank = i + 1}).ToList()

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.