也许我错过了一些东西。我有一个“地理”数据类型的 SQL Server 列。
我想在我的 C# 代码中使用 DbGeography 类型。有什么方法可以将 sql 的地理转换为 dbgeography 吗?
最佳答案
抱歉回复晚了 - 但在搜索其他内容时看到了这个。
只需执行以下操作:
SqlGeography theGeography;
int srid = 4326; // or alternative
DbGeography newGeography = DbGeography.FromText(theGeography.ToString(), srid);
要反转它:
DbGeography theGeography;
SqlGeography newGeography = SqlGeography.Parse(theGeography.AsText()).MakeValid();
希望有帮助!
关于sql-server - sql geography 到 dbgeography?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15107977/