Instead of select the top 3 records, I hope to select the top 3rd record in a single query.
Share
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.
Assuming your query already defines the right order in your result set, you can just skip the first two using
Skip()then finally take the third result, or null if it doesn’t exist (less than 3 results):Edit:
Actually this can be done shorter, since the
Take(1)andSingleOrDefault()can be expressed withFirstOrDefault()instead: