Is there a stricter version of .Single() such that an exception is thrown if more than one comes back from said query? I can always create an extension method, but wondered if I was reinventing something that already exists.
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.
Single()already throws anInvalidOperationExceptionif the result contains more than one element (or if it is empty). You were probably confusing it withFirst(), which doesn’t throw if there is more than one element.