Here’s the full message:
Getting LINQ to Entities does not recognize the method ‘Double GetProximityInMiles(double, double)’ method, and this method cannot be translated into a store expression.
Here’s the code:
public Maid[] GetMaidsByZipCode(string Zip, int Distance)
{
MaidsListEntities Context = new MaidsListEntities();
return Context.Maids.Where(m => m.Zip == Zip && Distance <= GeoLocationProvider.Instance.GetProximityInMiles(Zip, m.Zip)).ToArray();
}
You are seeing this error because your method (
GetProximityInMiles) could no be translated to a SQL query. You can try doing that part of the query in memory:The first call to ToArray materializes all the Maids. The rest of the query is then performed in memory.
Note that this approach might cause performance problems if the record count in your table is too big.