Reputation: 21368
I have following LINQ statement:
(from o in Table where (o.Username == username && o.Password == password) select o).SingleOrDefault()
it seems that this ignores Case. how do I make sure that "Test" != "test" etc. thanks
Upvotes: 0
Views: 362
Reputation: 107357
As per Klaus's comment, the problem is likely to be your SQL server CI setting
However, it is bad practice to store passwords cleartext in any event - you should look at hashing, or even better, use a security framework (like ASP.NET Membership) to manage these for you.
Upvotes: 2
Reputation: 55601
What LINQ provider are you using? It matters. E.g. LINQ to XML is case sensitive and you have to do ToUpperVariant() calls to become case insensitive and on SQL the behavior can vary based on sql collation settings.
Upvotes: 1
Reputation: 82933
LINQ is not ignorning the case, its the SQL Server. Change the COLLATION to make SQL Server case sensitive.
Upvotes: 7