LINQ StartsWith
, EndsWith
, and Contains
are case sensitive and return false
if two same string
s are of different cases, e.g., "STRING
" and "string
".
string name = "STRING";
var employees = context.employees.Where(emp => emp.Name.Contains(name));
If in database employee name="string
", no result will be returned. The most simple way is to convert both to lower case.
string name = "STRING";
var employees = context.employees.Where(emp => emp.Name.ToLower().Contains(name.ToLower()));