Reza Acolahchi
Reza Acolahchi

Reputation: 41

How can it happend a simple string condition ignore case-sensitive without any toLower method

I just write a simple method to get user data from database by "UserName" and its work but it's not case-sensitive , without any "toLower()" methods or something like that... and this is a big problem because it's think "Admin" equal to "admin" but this two actually not equal together ... please some body tell me what should I do???

public List<UserViewModel> GetByName(string userName)
        {
            return db.UserTBL.Where(u => u.UserName == userName).
                Select(u => new UserViewModel
                {
                    UserName = u.UserName,
                    UserFullName = u.UserFullName,
                    UserPassword = u.UserPassword,
                    UserImage = u.UserImage
                }).ToList();
        }

Upvotes: 1

Views: 67

Answers (2)

Reza Acolahchi
Reza Acolahchi

Reputation: 41

with guide guys give me here I do like picture below and it's work for me step 1 : choose the field in design mode step 2 : choose collation properties step 3 : choose windows collation step 4 : choose Dictionary sort step 5 : choose Case Sensitive and it's work for me
the five Steps I do

Upvotes: 0

Patrick Hofman
Patrick Hofman

Reputation: 156988

This is probably caused by your database being set up to match case-insensitive.

Check the collation settings of the database platform you are using. You can set it either globally, for the entire database, or for that column specifically.

Upvotes: 1

Related Questions