Link to home
Avatar of Philippe Renaud
Philippe RenaudFlag 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 ?
Avatar of Philippe Renaud
Philippe Renaud
Flag of Canada image

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
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial