小巧玲珑的空间地理类型 [英] Dapper Spatial Geography Type
问题描述
我做饭了一些空间的例子和决定给小巧玲珑一展身手,虽然EF有空间的支持,我爱再次有超过我的SQL控制(感谢萨姆和放大器;马克)。
I'm cooking up some spatial examples and have decided to give Dapper a go, although EF has spatial support, and I'm loving having control over my SQL again (Thanks Sam & Marc).
不过,我需要能够有POCO的支持的 DbGeography 的类。例如:
However, I need to be able to have POCO's that support the DbGeography class. For example :
public class BuriedTreasure {
public int PirateId { get; set; }
public DbGeography MarksTheSpot { get; set; }
}
我的谷歌富已经让我失望,最近的比赛我能找到 的问题,但它只是迎合添加作为参数的空间支持(所以它的50%有)。
My Google foo has been letting me down and the closest match I can find is this question, though it only caters for adding spatial support as a parameter (so it's 50% there).
现在就我看,我是仅限于下列选项中,其中既不对我来说是一个可行的解决方案。
Now as far as I can see I'm limited to the following options of which neither to me is a viable solution.
- 自定义短小精悍的代码来了解一个SQL Server特定类型
- 指定LONG,LAT和放大器;在我的POCO高程小数和我的存储过程创建空间类型和有另一个程序来检索值(或使用一个持久化计算列但这是几乎相同)
另外选择?
推荐答案
有关有兴趣的人,基本上是我在我张贴的问题了选项2以上。我有我的空间数据映射到小数。这个存储过程进行一些额外的检查,所以很容易构建点内,也就是下面的代码片段:
For anyone interested, essentially I went for option 2 in the question I posted above. I have my spatial data mapped to decimals. The stored procedure does some additional checking so it was easy to construct the point therein, ie the following snippet :
Yarrrr = geography::Point(@Latitude, @Longitude, 4326)
从本质上讲,DbGeography类是不可变的,去在所有需要短小精悍的节目...... RTFM :)
Essentially, the DbGeography class is immutable, goes to show... RTFM :)
没有变化!
这篇关于小巧玲珑的空间地理类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!