I have the following code.
var category = Office.Categories.FirstOrDefault(c => c.Description == name);
Office
is a Framework Entity object that was read earlier.
Even though my database uses case-insensitive string comparisons, and one of the items matches exactly except for the case, this code is returning null
.
My understanding of what is happening here is that Office.Categories
is returning all related rows, and then those rows are being searched by regular LINQ, which is case-sensitive.
If so, that is horribly inefficient as I only want to return the row that matches my condition.
Can anyone confirm my understanding of this? And is it possible to force the filtering to take place in SQL so that I don't need to return the rows I'm not interested in? (And the text comparison will be case-insensitive?)
Thanks for any help.