views:

1151

answers:

2

hi there,

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

+2  A: 

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.

Marc Climent
+1  A: 

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%5Fthread/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.

reach4thelasers