0

This is for the intranet. When I search for the username it comes out with lower case.

When I search for the username within the table it never finds the username because it seems it needs to be capitalized as it is also capitalized in the table.

Is there a way to make this work to work on any case when searching the table using SingleOrDefault?

var userNamenew = userName.Split('\\')[1]; //this equals to 'namel'
//var userNamenew = "NameL"; //this work
var CurrentUser = employee.SingleOrDefault(x => x.UserName == userNamenew);
Jlalonde
  • 483
  • 4
  • 13
anatp_123
  • 43
  • 6

1 Answers1

0

What about

employee.SingleOrDefault(x => x.UserName.ToLower() == userNamenew.ToLower());

And then you're comparing two lower case strings

Stuart.Sklinar
  • 3,683
  • 4
  • 35
  • 89