如何使用 C#、Entity Framework 和 SQL Server 2008 读取/写入地理数据?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10655857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to read / write geography data using C#, Entity Framework and SQL Server 2008?
提问by Filip Filipovi?
I have a form from which the user will be able to enter the latitude and longitude of a certain point on the map. The data will be input as string values. I did some research and found out from various sources that the Entity Framework doesn't support geography data types.
我有一个表单,用户可以从中输入地图上某个点的纬度和经度。数据将作为字符串值输入。我做了一些研究,从各种来源发现实体框架不支持地理数据类型。
- How can I parse and/or save the string data to a geography column in a database?
- How can I access it and reparse it as string once it is stored?
- 如何将字符串数据解析和/或保存到数据库中的地理列?
- 存储后如何访问它并将其重新解析为字符串?
Thanks in advance!
提前致谢!
采纳答案by Pawel
In fact Entity Framework 5 components that are shipped with .NET Framework 4.5 do support spatial types. Take a look at this walkthrough.
事实上,.NET Framework 4.5 附带的 Entity Framework 5 组件确实支持空间类型。看看这个演练。
EDITWith EF6 you can use spatial types on both .NET Framework 4 and .NET Framework 4.5
编辑使用 EF6,您可以在 .NET Framework 4 和 .NET Framework 4.5 上使用空间类型

