EF Query using .Contains() and .ToLowerInvariant() Results in no matches when match is found at the end of a string
Posted
by
MyNameIsJob
on Stack Overflow
See other posts from Stack Overflow
or by MyNameIsJob
Published on 2010-12-27T21:27:54Z
Indexed on
2011/01/04
15:53 UTC
Read the original article
Hit count: 181
Is it possible to step into a linq query? I have a linq to entity framework 4 query in it's simplest form:
List = List.Where(f => f.Value.ToString().ToLowerInvariant().Contains(filter.ToLowerInvariant()));
It's a query against an Entity Framework DbContext
and I'm having trouble seeing why it works for something like:
List searching for 001
yields no results against the following list
- Test001
- Test002
- Test003
- Test004
However any other search yields results (Such as t00
or Test
)
Update
Basically I'm looking for why a query such as the above wouldn't return a result when I'm using a contains and the value matches the end of a string vs just the middle or begining. It's really confusing.
OK, it appears to have something to do with ToLowerInvariant()
- when I removed that method it works just fine.
© Stack Overflow or respective owner