Click here to Skip to main content
12,898,569 members (64,956 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 4 Feb 2012

LINQ Query Case Sensitivity

, 4 Feb 2012 CPOL
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()));


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


About the Author

Kenya Kenya
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionMy 5 stars goes to relevance Pin
netfed15-Jan-16 0:15
membernetfed15-Jan-16 0:15 
GeneralReason for my vote of 1 Not at all good candidate for articl... Pin
aamironline4-Feb-12 17:42
memberaamironline4-Feb-12 17:42 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by Winstan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid