i have this MySQL statement from a search page, the user enters there postcode and it finds the nearest stiocklist within 15 MIles of the entered postcode.
SELECT * , (
(
ACOS( SIN( "+SENTLNG +" * PI( ) /180 ) * SIN( s_lat * PI( ) /180 ) + COS( " + SENTLNG +" * PI( ) /180 ) * COS( s_lat * PI( ) /180 ) * COS( (
" + SENTLANG + " - s_lng
) * PI( ) /180 ) ) *180 / PI( )
) *60 * 1.1515
) AS distance_miles
FROM new_stockists
WHERE s_lat IS NOT NULL
HAVING distance_miles <15
ORDER BY distance_miles ASC
LIMIT 0 , 15
but now i am using linq and subsonic and not got a clue how do do this in linq or subsonic
your help would be much appreciated, please also not that i have to sent in a dynamic from address, thats the postcode mentioned at the top of the page, i do a call to google to get then lng and lat from them for the postcode given.
You can create a stored procedure in MS SQL that does what your query does, and then call that query from your app. Linq does support stored procedures – kindof like this
It’s a little irritating to fall back to stored procs, but I don’t think the part of Linq that parses the Queryables expressiontrees can detect the revant math functions and map them to SQL.