Are there any appreciable performance differences between:
something.Where(predicate).FirstOrDefault();
and
something.FirstOrDefault(predicate);
?
I tend to use both, but am wondering if there’s a clear winner when it comes to performance.
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.
It depends on whether this
Whereis against anIQueryableorIEnumerable.In case of
IQueryablethe difference is based on implementation of the provider but it is more likely there will be no difference and would yield same query.In case of IEnumerable it should be negligible.