Reputation: 20358
I have SQL Server data base where i am storing city Name. Like "Delhi";
Example: I have samll word "delhi"
and collection of big string is "New Delhi", "Old Delhi", "Delhi ncr".
If I will make search any serach from big string then it will return all data from delhi city.
Please let me how can i do this.
I am using Linq to sql
and linq queries
.
My First Edit
In my table column City Saved as "delhi".
if I will make any search query like this "New Delhi","New delhi","Old Delhi" "Old delhi" or "delhi ncr" all should be return all data of "delhi" city.
Please suggest me query for this.
Upvotes: 1
Views: 152
Reputation: 2215
Try this out !!!
var result = City.Where(s=>s.cityName.ToLower().contains("delhi")).ToList();
Edited Answer
var result = City.Where(s => s.Name.ToLower().Split(' ').Contains("delhi")).ToList();
hope this helps !!!!
Upvotes: 3
Reputation: 8116
If you want a case-insensitive search, just use
String.Equals("delhi", "Delhi", StringComparison.InvariantCultureIgnoreCase)
in your linq query.
Upvotes: 1