I have the following scalar function in MS SQL 2005:
CREATE FUNCTION [dbo].[Distance] ( @lat1 float, @long1 float,@lat2 float, @long2 float )
RETURNS float
AS
BEGIN
RETURN (3958*3.1415926*sqrt((@lat2-@lat1)*(@lat2-@lat1) + cos(@lat2/57.29578)*cos(@lat1/57.29578)*(@long2-@long1)*(@long2-@long1))/180);
END
I need to be able to call this function from my NHibernate queries. I read over this article, but I got bogged down in some details that I didn't understand right away.
If you've used scalar functions with NHibernate, could you possibly give me an example of how your HBM file would look for a function like this?