NHibernate.Spatial and Sql 2008 Geography type
Asked Answered
W

2

13

i'm currently working on a project where i have to deal with sql server 2008 geography types. As big parts of the projects uses NHibernate as ORM i wonder how much work it will be to use/extend NHibernate.Spatial with this type (as far as i can see Nh Spatial only supports the geometry type yet). Btw. are there any other .net ORM's out there that support this sql type? thanks

Whortleberry answered 22/12, 2008 at 8:1 Comment(7)
I'm looking for the same thing. Have you discovered anything yet? Whats your current solution to nhibernate and sql server 2008 geography types?Rillis
i took Ricardo Stuven's SqlGeometry implementation from NHSpatial and extended it to work with SqlGeography type. there are still some minor bugs in it, but i can use IGeometry types and use geography as backend. I will send the code to the NHSP guys as soon as i get time to refactor/clean it up.Whortleberry
Cool. I look forward to seeing/using it.Rillis
I am looking forward to your addition to the NHSpatial project Joachim Kerschbaumer!Photomultiplier
@Joachim - did you manage to get this done? Thanks :-)Gersham
@Joachim - I would also like to see your implementation. I am struggling to get these types working with NHibernate.Gershwin
have you tried the code from the nhibernate.spatial subversion repository? i did a quick comparison and didn´t found great differences. the stuff ricardo stuven added to the repo should work imho.Whortleberry
D
2

I don't know specifically about spatial, but you can always extend NHibernate to deal with your custom types which is quite straightforward (see NHibernate Custom Mapping Types) but the thing is that you have to explain how to deal with geography types to NHibernate (see namespace NHibernate.Type) teling NH how to convert the value back and forth to SQL.

It may not be the easiest thing in the world but can be done, many people may help you in nhusers and you will definitely learn a lot about the inner workings of an OR/M.

Daile answered 30/1, 2009 at 10:4 Comment(0)
M
1

I asked the same thing in NHUsers back in January. NHSpatial has limited support for geography types. Check the thread at NHUsers below, you can 'sort of' use Geometry types for some Geography applications.

http://groups.google.com/group/nhcdevs/browse_thread/thread/752b046c0ce959b0/9596204d0dd0ff47?q=#9596204d0dd0ff47

Also see the link that Ricardo posted on the group to Isaac Kunen's blog which gives an interesting example of the nearest neighbour problem in SQL.

So basically, the answer: No NHSpatial doesn't support Geography, but you can use Geometry types for some basic geography problems (e.g distance between two points). But you're better off running a Native SQL query to get the full power of SQL Server 2008's geography types.

Misreckon answered 10/11, 2009 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.