I want user object only when exact password along with case matches. However this query fetches result even when case for password is not same:
db.Users.Where(u => u.Username.ToLower() == username.ToLower() &&
u.Password == password).FirstOrDefault();
What am I missing?
Simplest way is to do the username matching in the DB under it’s case-insensitve rules and the password matching in .NET under its case-sensitive rules:
The
ToList()moves from db-based LINQ to object-based LINQ, and since there would only be one matching case anyway, the performance impact of doing so is negligible.Still has the problem of storing a password in a database though!