I have the following query in SQL :
SELECT TOP 1 *
FROM sessions
ORDER BY start_time
How should I code it instead in LINQ-to-SQL
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
OrderByfor the ordering, andFirstor possiblyFirstOrDefaultfor the equivalent ofTOP 1:You could use a query expression for the first part, but it seems pretty pointless – it would end up being more long-winded than using “dot notation”, so I’d stick to that.