Using NHibernate Spatial

NHibernate Spatial brings the spatial capabilities of several relational databases to the NHibernate API. In this recipe, we'll show you how to use NHibernate Spatial with Microsoft SQL Server 2014 to query for a geographic region containing a point.

Getting ready

In SQL Server 2014 Express, create a new, blank database named Spatial.

Download State shapes from the US Census website by following these steps:

  1. Inside the solution directory, create a directory named SpatialData.
  2. Download the Shape file containing all 50 states, D.C., and Puerto Rico from the United States Census website at https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html or from the code download for this book. The file is named st99_d00_shp.zip ...

Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.