Hi,
How do I make sure that my filter [https://aspnetzero.com/Documents/Developing-Step-By-Step-Core#filtering-people]) is also case-insensitive (StringComparison.CurrentCultureIgnoreCase)?
Kind regards,
Riaan
3 Answer(s)
-
0
Hi,
I haven't tried with this Linq to Entities, have you tried it ? If it does not work I suggest you to search it on the internet because this is a topic related to Entity Framework.
Thanks.
-
0
Hi,
I see that we need to look at making use of the IEqualityComparer<T> Interface because of this being a ASPNETCOREZERO project and Contains() is not part of ASPNET CORE.
I will investigate the use of IEqualityComparere<T> for string case insensitive compares a bit later, but found the following solution (although not as elegant) to be working in the meantime for case-insensitive filtering:
var foodNotes = _foodNoteRepository .GetAll() .WhereIf( !input.Filter.IsNullOrEmpty(), p => p.Title.ToLower().Contains(input.Filter.ToLower()) || p.Detail.ToLower().Contains(input.Filter.ToLower())) .OrderBy(p => p.Title) .ThenBy(p => p.CreationTime) .ToList();
-
0
Hi @riaan,
Thank you for sharing your solution :)