Scalar-Valued Function in NHibernate

Posted by Byron Sommardahl on Stack Overflow See other posts from Stack Overflow or by Byron Sommardahl
Published on 2010-03-20T03:04:45Z Indexed on 2010/03/20 3:11 UTC
Read the original article Hit count: 463

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?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about scalar-function