Click here to Skip to main content
12,254,393 members (67,462 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11.7K views
Posted

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()));

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

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by Winstan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid