I am storing ZIP codes in my database and trying to convert the following T-SQL to Linq to Entity:
SELECT *
FROM Regions
WHERE EndZip >= '12345'
I'm trying something like the following code:
var result = this.DbContext.Regions.Where(e => e.EndZip.CompareTo("12345") >= 0);
but I get an EntityCommandExecutionException: "The binary operator GreaterThanOrEqual is not defined for the types 'System.String' and 'System.String'."
I was able to do this if I convert my IQueryable to an IEnumerable, but I would like this query to be executed in SQL for performance reasons.
Does anyone know how I can compare strings in Linq to Entity?