Hi!
I have a query on the server side that returns a list of distinct cities from a zipcode table.
I'm using WCF RIA Service.
The following query successfully returns 228 cities when provincename == ""
public IQueryable<CityPM> GetCities(string provinceName)
{
return this.ObjectContext.ZipCodes.Where(z => z.Province.Contains(provinceName))
.GroupBy(z => z.City)
.Select(g => g.FirstOrDefault())
.Select(zc => new CityPM() { ID = zc.ID, Name = zc.City });
}
but if I use ToLower() method as below, the query returns 0 cities when provincename == ""
.
public IQueryable<CityPM> GetCities(string provinceName)
{
return this.ObjectContext.ZipCodes.Where(z => z.Province.ToLower().Contains(provinceName.ToLower()))
.GroupBy(z => z.City)
.Select(g => g.FirstOrDefault())
.Select(zc => new CityPM() { ID = zc.ID, Name = zc.City });
}
Why isn't the query returning anything?