I am not able to upgrade to the new Entity Framework (4.0) so I have to use the first version (EFv1). Up to now I have been able to get by, but I am now stuck at the part where the LINQ query is trying to use the DistanceBetween database funcion in the where clause. Also note that I had to comment out the EdmFunctionAttribute - I believe that is an EFv4 feature only. Is there a way to do it in EFv1?
public static double DistanceBetween(double lat1, double long1, double lat2, double long2)
throw new NotImplementedException("Only call through LINQ expression");
public IQueryable<Dinner> NearestDinners(double latitude, double longitude)
return from d in entities.Dinners
where DistanceBetween(latitude, longitude, d.Latitude, d.Longitude) < 100
I get the following error:
System.NotSupportedException was unhandled by user code
Message="LINQ to Entities does not recognize the method 'Double DistanceBetween(Double, Double, Double, Double)' method, and this method cannot be translated into a store expression."
From what I've read, EFv1 does not support database functions, which seems like a major shortcoming if true. Does anyone have any ideas how I can get this to work? Thanks in advance.