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

Tagged as

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

Comments and Discussions

GeneralReason for my vote of 1 Not at all good candidate for articl... Pinmemberaamironline4-Feb-12 18: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 | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by Winstan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid