I don’t know the difference between FirstOrDefault and SingleOrDefault. When should I use the first and when should I use the second?
I don’t know the difference between FirstOrDefault and SingleOrDefault . When should I use
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.
FirstOrDefault()is for when zero or more results are expected to be present in the input collection and the call returns the first item if there are multiple results, Default if none.SingleOrDefault()is for when zero or one result is expected in the input collection and the call returns the one result if exactly one result is present, Default if no results and exception if more than one result.