I have an implementation of the Harversine formula in both c# and an example in TSQL.
I’m unsure how is best to implement the formula on the server side so I’m able to use it within a Linq query.
Ideally, I’d just have my local formula linked to the function on the server. Thus avoiding the “no translation to sql” error and having everything nice and seamless.
Obviously any view on the problem is helpful.
I’m aware of the Geography types in SQL2008. However the code base i’m working against already has such a reliance on Linq to SQL I’d expect It’s more effort than it’s worth!
Thanks
why not going 100% SQL as it’s the best way to make the calculations, and simply get a table already filled up with the distances?
from an existing answer
and used like:
but the best is always to have everything on SQL so your hosting server has less to do, simply ad a VIEW to your SQL and call that view, let’s imagine:
and use LINQ to call that view directly.