I have following code that creates Linq query.
I’ve never used Linq until today (shame on me) and having problem with “Order By Clause”
Dim products = dt.AsEnumerable()
Dim linq = From p In products _
Where p!Weight > 2 _
Take 20 _
Select p!Clarity, p!Color, p!Weight _
Order By p!Weight.Length
If I run the code, I get following error.
Name ‘p’ is either not declared or not in the current scope.
How come p!Weight in “Select Clause” works but not in “Order By Clause”?
Thank you
After the
Selectclause,pis no longer in scope.Move the
Order Byfirst.