Click here to Skip to main content
Click here to Skip to main content

Tagged as

LINQ Query Case Sensitivity

, 4 Feb 2012
Rate this:
Please Sign up or sign in to vote.
Case sensitive LINQ query

LINQ StartsWith, EndsWith, and Contains are case sensitive and return false if two same strings are of different cases, e.g., "STRING" and "string".

string name = "STRING";
var employees = context.employees.Where(emp => emp.Name.Contains(name));

If in database employee name="string", no result will be returned. The most simple way is to convert both to lower case.

string name = "STRING";
var employees = context.employees.Where(emp => emp.Name.ToLower().Contains(name.ToLower()));

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Winstan

Kenya Kenya
No Biography provided

Comments and Discussions

 
GeneralReason for my vote of 1 Not at all good candidate for articl... Pinmemberaamironline4-Feb-12 17:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by Winstan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid