Link to home
Start Free TrialLog in
Avatar of suroma
suromaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Linq query for top 1

i am trying to retrieve the top 1 object from the following query but it is not working as expected. Please help.
Dim LastQuestion As Question = (From q In qu Order By q.QuestionNumber Descending Take 1 Select q)

Open in new window

Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Try this


Dim LastQuestion As Question = (From q In qu Order By q.QuestionNumber Descending Select q).Take(1)
Sorry it was c# syntax.
give us your definition of qu
ASKER CERTIFIED SOLUTION
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also your Question has to implement IComparable
Avatar of suroma

ASKER

Works perfectly. Many thanks!