Originally I had this method:
public virtual User GetUser(string username)
{
return _db.Users.Single(x => x.UserName == username);
}
So basically a linq method which gets a user based on the person's username.
Trouble was I found that sometimes the username was coming through with an uppercase character at the start so it wasn't always working.
So then I came up with:
public virtual User GetUser(string username)
{
return _db.Users.Single(x => (string.Compare(x.UserName, username, true) == 0));
}
This works. However I get this must be really inefficient to do a string.Compare for the users?
Is there a better way to write this without the string.Compare?