sql geography to dbgeography?

前端 未结 6 1665
粉色の甜心
粉色の甜心 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:18

    Based on my reading of EntityFramework.SqlServer.dll in ILSpy, I believe the quickest way to convert from SqlGeography to DbGeography is:

    var dbGeo = System.Data.Entity.SqlServer.SqlSpatialServices.Default.GeographyFromProviderValue(sqlGeo);
    

    This method has the advantage that no binary conversion and parsing is required. It simply returns a DbGeography using the SqlGeography as the internal provider value.

提交回复
热议问题