Avatar of Philippe Renaud
Philippe Renaud
Flag for Canada asked on

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 ?
Visual Basic.NETC#LINQ Query

Avatar of undefined
Last Comment
Miguel Oz

8/22/2022 - Mon
Philippe Renaud

ASKER
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

ASKER CERTIFIED SOLUTION
Miguel Oz

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23