Using SQL Server 2008 Geography types with nHibernate's CreateSQLQuery

后端 未结 4 1185
春和景丽
春和景丽 2021-01-01 06:54

I am trying to issue a SQL update statement with nHibernate (2.0.1GA) like this:

sqlstring = string.Format(\"set nocount on;update myusers set geo=geography:         


        
4条回答
  •  迷失自我
    2021-01-01 07:30

    Following on @Chris's answer, here is a copy and paste solution:

    CREATE FUNCTION GetPoint 
    (
        @lat float,
        @lng float,
        @srid int
    )
    RETURNS geography
    AS
    BEGIN
    
    declare @point geography = geography::Point(@lat, @lng, @srid);
    
    RETURN @point
    
    END
    GO
    

    The you do

    dbo.GetPoint(@Latitude, @Longitude, 4326)
    

    instead of

    geography::Point(@Latitude, @Longitude, 4326);
    

    And NH is happy

提交回复
热议问题