且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.net 4.5 中是否有类似 dbgeometry makevalid 的东西

更新时间:2023-11-28 23:43:04

我同意 Bojan 的观点,除非你使用实体框架?

I'd agree with Bojan, unless you are using the Entity Framework?

SqlGeometry 对象有一个 MakeValid() 函数,因此使用您的示例,允许在 DbGeography 和 SqlGeography 之间进行转换:

The SqlGeometry object has a MakeValid() function, so using your example, allowing for a convert between DbGeography and SqlGeography:

DbGeography geog;
SqlGeometry geom = SqlGeometry.STGeomFromWKB(new SqlBytes(geog.AsBinary()), 32637);

但是,除非您使用 EF,否则我建议您只使用 SqlGeometry 作为

However, unless you are using EF, I'd recommend simply using SqlGeometry as

  1. 没有演员表/转换
  2. SqlGeometry 具有比 DbGeometry 多得多的功能.

希望有所帮助.