Can I improve this LINQ query
var filter = from Dep in deptlist
where (Dep.DepNm.StartsWith(txt1.Text.ToLower())
|| Dep.DepNm.StartsWith(txt1.Text.ToUpper())
||Dep.DepNm.Contains(txt1.Text))
select Dep;
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.
Currently, you do a
.Text,.Text.ToUpper()and.Text.ToLower()of the fixed value per item; (theToUpper()etc being relatively expensive); you can lift this out:I’m assuming here that
.DepNmis trivially cheap. If this is actually an expensive property to query, you can useletto minimise the calls: