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
LINQ is not ignorning the case, its the SQL Server. Change the COLLATION to make SQL Server case sensitive.
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.
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.
精彩评论