I am currently working on an application that will retrieve other users' locations based on distance.
I have a database that store all the user location information in latitude and longitude. Since the calculation of distance between these two pairs of latitude and longitude is quite complicated, I need a function to handle it.
from a in db.Location.Where(a => (calDistance(lat, longi, Double.Parse(a.latitude), Double.Parse(a.longitude)))<Math.Abs(distance) )) {...}
However, I got the following error: LINQ to Entities does not recognize the method and this method cannot be translated into a store expression.
I don't know how to translated it into a store expression and also, the calculation also need the math library.
Is there any method that i can do to let the LINQ expression call my own function?
Maybe there are other ways to achieve my goal, can anyone help?