user979331 user979331 - 24 days ago 8
ASP.NET (C#) Question

ASP.NET Entity Framework Using Trim() in where clause not working

I have this line of code:

var community = dbCommunity.Data.Where(m => ==; is "TorontoCanada" but in my database I have them saved as "Toronto Ontario", what I am trying to do is Trim the white space for the data column. I tried Trim() but this returns null.

Please Help!

Answer Source

You don't need trim() here, you need Replace(" ", ""). Also, trim() deletes the whitespace from both ends of a string, and is hence not usable in your scenario.