sql geography to dbgeography?

前端 未结 6 1678
粉色の甜心
粉色の甜心 2020-12-03 01:31

Maybe I\'m missing something. I have a sql server column of the \"Geography\" datatype.

I want to use the DbGeography type in my c# code. Any way to cast or convert

6条回答
  •  心在旅途
    2020-12-03 02:17

    When the performance is of any importance, the well-known binary should be used instead of the well-known text:

    var newGeography = DbGeography.FromBinary(theGeography.STAsBinary().Value);
    

    There is an overload using a SRID, if that is important. In my simple test with a 1,000 reasonably complicated polygons the binary-based approach is 4 times faster than the text-based one:

    * Binary-based conversion
    Run 1: 1948
    Run 2: 1944
    Run 3: 1959
    Run 4: 1979
    Run 5: 1988
    Average: 1963.6
    
    * Text-based conversion
    Run 1: 8527
    Run 2: 8553
    Run 3: 8596
    Run 4: 8535
    Run 5: 8496
    Average: 8541.4
    

提交回复
热议问题