这两个对象在Microsoft数据库中表示相同的地理数据类型,其目的或目的是什么?
System.Data.Entity.Spatial.DbGeography和
Microsoft.SqlServer.Types.SqlGeography它们不能相互转换,但是SqlGeography在创建点、多边形等方面有额外的命令。
我认为System.Data.Entity只适用于实体框架,而Microsoft.SqlServer是直接使用SqlCommand时使用的吗?
发布于 2014-04-20 20:07:56
你说得对,本质上就是这么简单。DbGeography只是一个简化的SqlGeography版本,旨在在Entity Framework中工作。最流行的SqlGeography方法已经在其中实现了,但正如您正确指出的那样,并不是所有的方法都实现了。
虽然这两种类型不能相互直接转换,但在需要SqlGeography的附加功能时,转换它们的过程相对简单。
例如:
SqlGeography geog1 = SqlGeography.STPolyFromText('<coords>', srid);
SqlGeography geog2;
DbGeography dbGeog;
// SqlGeography to DbGeography
dbGeog = DbGeography.FromText(geog1.ToString(), srid);
// DbGeography to SqlGeography
geog2 = SqlGeography.Parse(dbGeog.AsText());https://stackoverflow.com/questions/23186832
复制相似问题