Page 1 of 1

query no case sensitive with Contains string

Posted: Sat 23 Mar 2019 08:38
by ratm
Hi, can anyone tell me how you can make it so that in the non-match between strings it's not case sensitive in a query?
var list = (from p in context.Patient
                         where p.Name.Contains (query) || p.Cognome.Contains (query)
                         orderby p.Name, p.Cognome
                         select p) .ToList ();
In this query the contains is case sensitive and therefore does not return a correct result. how can I do?

Re: query no case sensitive with Contains string

Posted: Mon 25 Mar 2019 16:14
by Shalex
Try this way:

Code: Select all

p.Name.Contains("some string")

->

p.Name.ToUpper().Contains("some string".ToUpper())

Re: query no case sensitive with Contains string

Posted: Tue 26 Mar 2019 10:51
by Shalex
One more solution is to change the column data type to citext: https://www.postgresql.org/docs/current/citext.html.