<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://nhforge.org/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Spatial</title><link>http://nhforge.org/wikis/spatial/default.aspx</link><description>Learn about this NHibernate extension allowing you to easily handle geographic data in a standard way.</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/0.aspx</link><pubDate>Wed, 06 Oct 2010 18:51:41 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:37</guid><dc:creator>Ricardo Stuven</dc:creator><description>Current revision posted to Spatial by Ricardo Stuven on 06/10/2010 03:51:41 p.m.&lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;NHibernate.Spatial&lt;/strong&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using &lt;a href="http://code.google.com/p/nettopologysuite/"&gt;NetTopologySuite&lt;/a&gt;, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a class="externalLink" href="http://www.hibernatespatial.org/"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Features:&amp;nbsp;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Geometry types:&lt;/strong&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with &lt;a href="http://www.opengeospatial.org/standards/sfs"&gt;OGC specifications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dialects:&lt;/strong&gt;&amp;nbsp;&lt;a class="externalLink" href="http://codeplex.com/MsSqlSpatial"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a class="externalLink" href="http://www.postgis.org/"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="http://dev.mysql.com/doc/refman/6.0/en/spatial-extensions.html"&gt;MySQL&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a class="externalLink" href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Criteria:&lt;/strong&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Intersects&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Within&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Crosses&lt;/span&gt;&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Projections:&lt;/strong&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schema generation:&lt;/strong&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metadata mappings:&lt;/strong&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;&amp;nbsp;classes.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate &lt;span style="text-decoration: line-through; color: red;"&gt;2.0.1.GA&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;2.1.2.GA&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/5.aspx</link><pubDate>Wed, 08 Oct 2008 17:20:48 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:350</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 5 posted to Spatial by Ricardo Stuven on 08/10/2008 02:20:48 p.m.&lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;NHibernate.Spatial&lt;/strong&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using &lt;a href="http://code.google.com/p/nettopologysuite/"&gt;NetTopologySuite&lt;/a&gt;, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a href="http://www.hibernatespatial.org/" class="externalLink"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Features:&amp;nbsp;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Geometry types:&lt;/strong&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with &lt;a href="http://www.opengeospatial.org/standards/sfs"&gt;OGC specifications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dialects:&lt;/strong&gt;&amp;nbsp;&lt;a href="http://codeplex.com/MsSqlSpatial" class="externalLink"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a href="http://www.postgis.org/" class="externalLink"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="http://dev.mysql.com/doc/refman/6.0/en/spatial-extensions.html"&gt;MySQL&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx" class="externalLink"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Criteria:&lt;/strong&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Intersects&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Within&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Crosses&lt;/span&gt;&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Projections:&lt;/strong&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schema generation:&lt;/strong&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metadata mappings:&lt;/strong&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;&amp;nbsp;classes.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate 2.0.1.GA&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/4.aspx</link><pubDate>Wed, 08 Oct 2008 13:56:04 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:170</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 4 posted to Spatial by Ricardo Stuven on 08/10/2008 10:56:04 a.m.&lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;NHibernate.Spatial&lt;/strong&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using &lt;a href="http://code.google.com/p/nettopologysuite/"&gt;NetTopologySuite&lt;/a&gt;, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a class="externalLink" href="http://www.hibernatespatial.org/"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Features:&lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Geometry types:&lt;/strong&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with &lt;a href="http://www.opengeospatial.org/standards/sfs"&gt;OGC specifications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dialects:&lt;/strong&gt;&amp;nbsp;&lt;a class="externalLink" href="http://codeplex.com/MsSqlSpatial"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a class="externalLink" href="http://www.postgis.org/"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="http://dev.mysql.com/doc/refman/6.0/en/spatial-extensions.html"&gt;&lt;span style="background: SpringGreen;"&gt;MySQL&lt;/span&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a class="externalLink" href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Criteria:&lt;/strong&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Intersects&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Within&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Crosses&lt;/span&gt;&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Projections:&lt;/strong&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schema generation:&lt;/strong&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metadata mappings:&lt;/strong&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;&amp;nbsp;classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate 2.0.1.GA&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/3.aspx</link><pubDate>Wed, 01 Oct 2008 03:09:08 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:169</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 3 posted to Spatial by Ricardo Stuven on 01/10/2008 12:09:08 a.m.&lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;NHibernate.Spatial&lt;/b&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using &lt;a href="http://code.google.com/p/nettopologysuite/"&gt;NetTopologySuite&lt;/a&gt;, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a href="http://www.hibernatespatial.org/" class="externalLink"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;h4&gt;Features:&lt;/h4&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Geometry types:&lt;/b&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with &lt;a href="http://www.opengeospatial.org/standards/sfs"&gt;OGC specifications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Dialects:&lt;/b&gt;&amp;nbsp;&lt;a href="http://codeplex.com/MsSqlSpatial" class="externalLink"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a href="http://www.postgis.org/" class="externalLink"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx" class="externalLink"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Criteria:&lt;/b&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Intersects&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Within&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Crosses&lt;/span&gt;&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Projections:&lt;/b&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Schema generation:&lt;/b&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Metadata mappings:&lt;/b&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;&amp;nbsp;classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate &lt;span style="text-decoration: line-through; color: red;"&gt;2.0.1&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;2.0.1.GA&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;</description></item><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/2.aspx</link><pubDate>Fri, 26 Sep 2008 22:05:59 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:162</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 2 posted to Spatial by Ricardo Stuven on 26/09/2008 07:05:59 p.m.&lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;NHibernate.Spatial&lt;/b&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using &lt;a href="http://code.google.com/p/nettopologysuite/"&gt;NetTopologySuite&lt;/a&gt;, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a href="http://www.hibernatespatial.org/" class="externalLink"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;h4&gt;Features:&lt;/h4&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Geometry types:&lt;/b&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with &lt;span style="text-decoration: line-through; color: red;"&gt;OGCspecifications&lt;/span&gt;&lt;a href="http://www.opengeospatial.org/standards/sfs"&gt;&lt;span style="background: SpringGreen;"&gt;OGC&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;specifications&lt;/span&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Dialects:&lt;/b&gt;&amp;nbsp;&lt;a href="http://codeplex.com/MsSqlSpatial" class="externalLink"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a href="http://www.postgis.org/" class="externalLink"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx" class="externalLink"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Criteria:&lt;/b&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Intersects&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Within&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;Crosses&lt;/span&gt;&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Projections:&lt;/b&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Schema generation:&lt;/b&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Metadata mappings:&lt;/b&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class="codeInline"&gt;&lt;span style="font-family:courier new,courier;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;&amp;nbsp;classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate 2.0.1&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;</description></item><item><title>Introduction</title><link>http://nhforge.org/wikis/spatial/introduction/revision/1.aspx</link><pubDate>Fri, 26 Sep 2008 21:23:13 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:157</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 1 posted to Spatial by Ricardo Stuven on 26/09/2008 06:23:13 p.m.&lt;br /&gt;
&lt;p&gt;&lt;b&gt;NHibernate.Spatial&lt;/b&gt;, spatial extensions for NHibernate, allows you to connect NHibernate to a spatially enabled database and manipulate geometries in HQL or in .NET code using NetTopologySuite, providing you with a fully integrated GIS programming experience.&lt;br /&gt;&lt;br /&gt;There is also a similar but independent effort for Java:&amp;nbsp;&lt;a class="externalLink" href="http://www.hibernatespatial.org/"&gt;Hibernate Spatial&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;h4&gt;Features:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Geometry types:&lt;/b&gt;&amp;nbsp;Geometry columns are mapped to .NET geometry types compliant with OGCspecifications.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Dialects:&lt;/b&gt;&amp;nbsp;&lt;a class="externalLink" href="http://codeplex.com/MsSqlSpatial"&gt;MsSqlSpatial,&lt;/a&gt;&amp;nbsp;&lt;a class="externalLink" href="http://www.postgis.org/"&gt;PostGIS&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a class="externalLink" href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx"&gt;SQL Server 2008&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;are supported. The most common spatial functions are registered for use within HQL, providing compatible queries among different dialects.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Criteria:&lt;/b&gt;&amp;nbsp;Spatial relations functions such as&amp;nbsp;&lt;span class="codeInline"&gt;Intersects&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;Within&lt;/span&gt;,&amp;nbsp;&lt;span class="codeInline"&gt;Crosses&lt;/span&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Projections:&lt;/b&gt;&amp;nbsp;Spatial aggregate, analysis and tranformation functions.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Schema generation:&lt;/b&gt;&amp;nbsp;Support for automatic creation and droping of auxiliary data objects (eg. registering of geometry columns in metadata table).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Metadata mappings:&lt;/b&gt;&amp;nbsp;Built-in mappings to spatial metadata through&amp;nbsp;&lt;span class="codeInline"&gt;GeometryColumns&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class="codeInline"&gt;SpatialReferenceSystem&lt;/span&gt;&amp;nbsp;classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Requirements:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;.NET 2.0&lt;/li&gt;
&lt;li&gt;NHibernate 2.0.1&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Installation:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Download latest sources and build. Copy the binaries to your project&amp;#39;s libraries folder.&lt;/li&gt;
&lt;li&gt;In you project, add references to &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NetTopologySuite.dll&lt;/span&gt;, &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;GeoAPI.dll&lt;/span&gt; and to provider assembly (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;NHibernate.Spatial.PostGis.dll&lt;/span&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/0.aspx</link><pubDate>Tue, 21 Jul 2009 20:50:35 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:38</guid><dc:creator>Ricardo Stuven</dc:creator><description>Current revision posted to Spatial by Ricardo Stuven on 21/07/2009 05:50:35 p.m.&lt;br /&gt;
&lt;h2&gt;Configuration and mapping&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Dialect Configuration: &lt;/h4&gt;
&lt;div class="wikidoc"&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a href="http://www.castleproject.org/activerecord/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;add key=&amp;quot;dialect&amp;quot; value=&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;MsSql2008Spatial&lt;/span&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;Dialect&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.) and &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;SomeSpatialAssembly&lt;/span&gt; by the assembly name where it is located (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;NHibernate.Spatial.MsSql2008&lt;/span&gt;)&lt;/p&gt;
&lt;h4&gt;&lt;/h4&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Declarative:&lt;/strong&gt; Use of &lt;a href="/doc/nh/en/index.html#mapping-database-object" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Programmatic:&lt;/strong&gt;&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;
&lt;pre&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;Configuration cfg = new Configuration();&lt;br /&gt;    // Your configuration code (eg. cfg.Configure(); )&lt;br /&gt;    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;/pre&gt;
&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier;"&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use a &lt;a href="/doc/nh/en/index.html#toolsetguide-s1-3" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a href="/doc/nh/en/index.html#configuration-optional" class="externalLink"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ActiveRecord Schema Generation Configuration:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You will need to add the SpatialAuxiliaryDatabaseObject in the Application_OnStart:&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;&lt;span&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt; using NHibernate.Cfg;&lt;br /&gt; using NHibernate.Spatial.Mapping;&lt;br /&gt;&lt;br /&gt; public void Application_OnStart()&lt;br /&gt; {&lt;br /&gt;    foreach (Configuration cfg in ActiveRecordMediator.GetSessionFactoryHolder().GetAllConfigurations())&lt;br /&gt;    {&lt;br /&gt;        cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;br /&gt;        Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);&lt;br /&gt;        Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;br /&gt;    }&lt;br /&gt; }&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;You can then generate the database schema in the usual way.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
&lt;p&gt;There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;Configuration cfg = new Configuration();&lt;br /&gt;// Your configuration code (eg. cfg.Configure(); )&lt;br /&gt;Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);&lt;br /&gt;Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;WARNING:&lt;/strong&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;/p&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;strong&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;&lt;br /&gt;        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;&lt;br /&gt;    &amp;lt;/type&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;private GeoAPI.Geometries.IGeometry _geometry; &lt;br /&gt;public virtual GeoAPI.Geometries.IGeometry Geometry&lt;br /&gt;{&lt;br /&gt;	get&lt;br /&gt;	{&lt;br /&gt;		return this._geometry;&lt;br /&gt;	}&lt;br /&gt;	set&lt;br /&gt;	{&lt;br /&gt;		this._geometry = value;&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;private GeoAPI.Geometries.IGeometry _geometry; &lt;br /&gt;         &lt;br /&gt;[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]&lt;br /&gt;public virtual GeoAPI.Geometries.IGeometry Geometry&lt;br /&gt;{&lt;br /&gt;	get&lt;br /&gt;	{&lt;br /&gt;		return this._geometry;&lt;br /&gt;	}&lt;br /&gt;	set&lt;br /&gt;	{&lt;br /&gt;		this._geometry = value;&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Type parameters (see &lt;strong&gt;NHibernate mapping&lt;/strong&gt; above) are not supported in ActiveRecord.&lt;/p&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;p&gt;&lt;a href="http://www.altinoren.com/activewriter/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a href="http://www.altinoren.com/activewriter/downloads.htm" class="externalLink"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example usage:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;
&amp;lt;tbody&amp;gt; 
&amp;lt;tbody&amp;gt;
&amp;lt;/tbody&amp;gt; 
&amp;lt;/tbody&amp;gt;
&amp;lt;tbody&amp;gt;
&lt;span style="background: SpringGreen;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;table style="border-collapse:collapse;border:#bbbbbb 0.1em solid;"&gt;
&lt;tbody&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Property&lt;/th&gt;&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;Custom&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Member Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Type parameters (see &lt;strong&gt;NHibernate mapping&lt;/strong&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/5.aspx</link><pubDate>Thu, 27 Nov 2008 14:33:13 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:292</guid><dc:creator>oharab</dc:creator><description>Revision 5 posted to Spatial by oharab on 27/11/2008 11:33:13 a.m.&lt;br /&gt;
&lt;h2&gt;Configuration and mapping&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Dialect Configuration: &lt;/h4&gt;
&lt;div class="wikidoc"&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a class="externalLink" href="http://www.castleproject.org/activerecord/"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;add key=&amp;quot;dialect&amp;quot; value=&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;MsSql2008Spatial&lt;/span&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;Dialect&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.) and &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;SomeSpatialAssembly&lt;/span&gt; by the assembly name where it is located (eg. &lt;span style="font-family:&amp;#39;courier new&amp;#39;,courier;"&gt;NHibernate.Spatial.MsSql2008&lt;/span&gt;)&lt;/p&gt;
&lt;h4&gt;&lt;/h4&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Declarative:&lt;/b&gt; Use of &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-database-object"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Programmatic:&lt;/b&gt;&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;
&lt;pre&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;Configuration cfg = new Configuration();&lt;br /&gt;    // Your configuration code (eg. cfg.Configure(); )&lt;br /&gt;    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;/pre&gt;
&lt;br /&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier;"&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use a &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/toolsetguide.html#toolsetguide-s1-3"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style="background: SpringGreen;"&gt;ActiveRecord&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Generation&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Configuration&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;will&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;need&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;to&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;add&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SpatialAuxiliaryDatabaseObject&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Application_OnStart&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;&lt;span&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.Cfg&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style="background: SpringGreen;"&gt;using&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;NHibernate.Spatial.Mapping&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="background: SpringGreen;"&gt;public&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;void&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;Application_OnStart(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;foreach&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;Configuration&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;cfg&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;ActiveRecordMediator.GetSessionFactoryHolder().GetAllConfigurations()&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;cfg.AddAuxiliaryDatabaseObject(new&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;SpatialAuxiliaryDatabaseObject(cfg))&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;Metadata.AddMapping(cfg&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;MetadataClass.GeometryColumn)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="background: SpringGreen;"&gt;Metadata.AddMapping(cfg&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;,&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;MetadataClass.SpatialReferenceSystem)&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="background: SpringGreen;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style="background: SpringGreen;"&gt;You&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;can&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;then&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;generate&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;database&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;schema&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;in&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;usual&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;way&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
&lt;p&gt;There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;Configuration cfg = new Configuration();&lt;br /&gt;// Your configuration code (eg. cfg.Configure(); )&lt;br /&gt;Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);&lt;br /&gt;Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;WARNING:&lt;/b&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;/p&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;&lt;br /&gt;        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;&lt;br /&gt;    &amp;lt;/type&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;private GeoAPI.Geometries.IGeometry _geometry; &lt;br /&gt;public virtual GeoAPI.Geometries.IGeometry Geometry&lt;br /&gt;{&lt;br /&gt;	get&lt;br /&gt;	{&lt;br /&gt;		return this._geometry;&lt;br /&gt;	}&lt;br /&gt;	set&lt;br /&gt;	{&lt;br /&gt;		this._geometry = value;&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;&lt;pre style="border:0.1em dashed #3e62a6;padding:0.5em;margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;"&gt;private GeoAPI.Geometries.IGeometry _geometry; &lt;br /&gt;         &lt;br /&gt;[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]&lt;br /&gt;public virtual GeoAPI.Geometries.IGeometry Geometry&lt;br /&gt;{&lt;br /&gt;	get&lt;br /&gt;	{&lt;br /&gt;		return this._geometry;&lt;br /&gt;	}&lt;br /&gt;	set&lt;br /&gt;	{&lt;br /&gt;		this._geometry = value;&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord.&lt;/p&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;p&gt;&lt;a class="externalLink" href="http://www.altinoren.com/activewriter/"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a class="externalLink" href="http://www.altinoren.com/activewriter/downloads.htm"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example usage:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;font-family:&amp;#39;Segoe UI&amp;#39;;color:#000000;"&gt;
&amp;lt;tbody&amp;gt; 
&amp;lt;tbody&amp;gt;
&amp;lt;/tbody&amp;gt; 
&amp;lt;/tbody&amp;gt;
&lt;table style="border-collapse:collapse;border:#bbbbbb 0.1em solid;"&gt;
&amp;lt;tbody&amp;gt;
&lt;tbody&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Property&lt;/th&gt;&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;Custom&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Member Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&amp;lt;/tbody&amp;gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/span&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/4.aspx</link><pubDate>Wed, 08 Oct 2008 00:17:54 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:200</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 4 posted to Spatial by Ricardo Stuven on 07/10/2008 09:17:54 p.m.&lt;br /&gt;
&lt;h2&gt;Configuration and mapping&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Dialect Configuration: &lt;/h4&gt;
&lt;div class="wikidoc"&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;hibernate.dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;lt;/property&amp;gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;&amp;quot;dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;lt;/property&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a class="externalLink" href="http://www.castleproject.org/activerecord/"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;add key=&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;hibernate.dialect&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;dialect&amp;quot;&lt;/span&gt; value=&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;quot;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,SomeSpatialAssembly&amp;quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used &lt;span style="text-decoration: line-through; color: red;"&gt;.&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;For&lt;/span&gt; &lt;span style="text-decoration: line-through; color: red;"&gt;example&lt;/span&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;,&lt;/span&gt; &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="text-decoration: line-through; color: red;"&gt;MsSqlSpatialDialect&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;eg.&lt;/span&gt; &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="background: SpringGreen;"&gt;MsSql2008Spatial&lt;/span&gt;&lt;/span&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="background: SpringGreen;"&gt;Dialect&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;.&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;and&lt;/span&gt; &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="background: SpringGreen;"&gt;SomeSpatialAssembly&lt;/span&gt;&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;by&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;the&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;assembly&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;name&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;where&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;it&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;is&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;located&lt;/span&gt; &lt;span style="background: SpringGreen;"&gt;(&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;eg.&lt;/span&gt; &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="background: SpringGreen;"&gt;NHibernate.Spatial.MsSql2008&lt;/span&gt;&lt;/span&gt;&lt;span style="background: SpringGreen;"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;&lt;/h4&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Declarative:&lt;/strong&gt; Use of &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-database-object"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Programmatic:&lt;/strong&gt;&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
    // Your configuration code (eg. cfg.Configure(); )
    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;/pre&gt;
&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier;"&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use a &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/toolsetguide.html#toolsetguide-s1-3"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a class="externalLink" href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;/p&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
&lt;p&gt;There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
// Your configuration code (eg. cfg.Configure(); )
Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;WARNING:&lt;/strong&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;/p&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;strong&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;
    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;
        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;
        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;
    &amp;lt;/type&amp;gt;
&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
         
[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Type parameters (see &lt;strong&gt;NHibernate mapping&lt;/strong&gt; above) are not supported in ActiveRecord.&lt;/p&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;p&gt;&lt;a class="externalLink" href="http://www.altinoren.com/activewriter/"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a class="externalLink" href="http://www.altinoren.com/activewriter/downloads.htm"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example usage:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&amp;lt;tbody&amp;gt; 
&amp;lt;tbody&amp;gt;
&lt;span style="background: SpringGreen;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt; 
&lt;span style="background: SpringGreen;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;table style="border-collapse:collapse;border:#bbbbbb 0.1em solid;"&gt;
&lt;span style="background: SpringGreen;"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Property&lt;/th&gt;&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;Custom&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Member Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;span style="text-decoration: line-through; color: red;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt; 
&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&amp;lt;/tbody&amp;gt;
&lt;/table&gt;
&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Type parameters (see &lt;strong&gt;NHibernate mapping&lt;/strong&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/3.aspx</link><pubDate>Fri, 26 Sep 2008 22:20:59 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:164</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 3 posted to Spatial by Ricardo Stuven on 26/09/2008 07:20:59 p.m.&lt;br /&gt;
&lt;h2&gt;Configuration and mapping&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Dialect Configuration: &lt;/h4&gt;
&lt;div class="wikidoc"&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;hibernate.dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a href="http://www.castleproject.org/activerecord/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;add key=&amp;quot;hibernate.dialect&amp;quot; value=&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used. For example, &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;MsSqlSpatialDialect&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;h4&gt;&lt;/h4&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Declarative:&lt;/b&gt; Use of &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-database-object" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Programmatic:&lt;/b&gt;&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
    // Your configuration code (eg. cfg.Configure(); )
    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;/pre&gt;
&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier;"&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use a &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/toolsetguide.html#toolsetguide-s1-3" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional" class="externalLink"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;/p&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
&lt;p&gt;There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
// Your configuration code (eg. cfg.Configure(); )
Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;WARNING:&lt;/b&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;/p&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;
    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;
        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;
        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;
    &amp;lt;/type&amp;gt;
&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
         
[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord.&lt;/p&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;p&gt;&lt;a href="http://www.altinoren.com/activewriter/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a href="http://www.altinoren.com/activewriter/downloads.htm" class="externalLink"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example usage:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;table style="border-collapse:collapse;border:#bbbbbb 0.1em solid;"&gt;
&amp;lt;tbody&amp;gt; 
&lt;span style="background: SpringGreen;"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Property&lt;/th&gt;&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;Custom&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Member Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span class="codeInline" style="font-family:&amp;#39;Courier New&amp;#39;;"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;span style="background: SpringGreen;"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt; 
&amp;lt;/tbody&amp;gt;
&lt;/table&gt;
&lt;/span&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/2.aspx</link><pubDate>Fri, 26 Sep 2008 22:18:57 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:159</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 2 posted to Spatial by Ricardo Stuven on 26/09/2008 07:18:57 p.m.&lt;br /&gt;
&lt;h2&gt;Configuration and mapping&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Dialect Configuration: &lt;/h4&gt;
&lt;div class="wikidoc"&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;hibernate.dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a href="http://www.castleproject.org/activerecord/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;add key=&amp;quot;hibernate.dialect&amp;quot; value=&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used. For example, &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;MsSqlSpatialDialect&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Declarative:&lt;/b&gt; Use of &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-database-object" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Programmatic:&lt;/b&gt;&amp;nbsp;&lt;span style="font-family:courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;font face="courier new,courier"&gt;&lt;font class="Apple-style-span" color="#000000" face="&amp;#39;Segoe UI&amp;#39;" style="word-spacing:0px;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
    // Your configuration code (eg. cfg.Configure(); )
    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));&lt;/pre&gt;
&lt;/pre&gt;
&lt;/font&gt;
&lt;/font&gt;&lt;/span&gt;&lt;font face="courier new,courier"&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use a &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/toolsetguide.html#toolsetguide-s1-3" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional" class="externalLink"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;/p&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
&lt;p&gt;There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Configuration cfg = new Configuration();
// Your configuration code (eg. cfg.Configure(); )
Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;WARNING:&lt;/b&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;/p&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;
    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;
        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;
        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;
    &amp;lt;/type&amp;gt;
&amp;lt;/property&amp;gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
         
[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord.&lt;/p&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;p&gt;&lt;a href="http://www.altinoren.com/activewriter/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a href="http://www.altinoren.com/activewriter/downloads.htm" class="externalLink"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example usage:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;font:13px &amp;#39;Segoe UI&amp;#39;;text-transform:none;color:#000000;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;" class="Apple-style-span"&gt;
&lt;table style="border-collapse:collapse;border:#bbbbbb 0.1em solid;"&gt;
&amp;lt;tbody&amp;gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Property&lt;/th&gt;&lt;th style="font-weight:bold;vertical-align:bottom;border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;Custom&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Column Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="border:#bbbbbb 0.1em solid;"&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;Custom Member Type&lt;/td&gt;
&lt;td style="border:#bbbbbb 0.1em solid;padding:0.25em;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;" class="codeInline"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&amp;lt;/tbody&amp;gt;
&lt;/table&gt;
&lt;/span&gt;&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;/p&gt;</description></item><item><title>Configuration and mapping</title><link>http://nhforge.org/wikis/spatial/configuration-and-mapping/revision/1.aspx</link><pubDate>Fri, 26 Sep 2008 21:29:14 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:158</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 1 posted to Spatial by Ricardo Stuven on 26/09/2008 06:29:14 p.m.&lt;br /&gt;
&lt;div class="wikidoc"&gt;
&lt;h4&gt;Dialect Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the NHibernate section of your configuration file add the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&amp;lt;property name=&amp;quot;hibernate.dialect&amp;quot;&amp;gt;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If you&amp;#39;re using &lt;a href="http://www.castleproject.org/activerecord/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;Castle ActiveRecord&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;, the entry will look like this: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&amp;lt;add key=&amp;quot;hibernate.dialect&amp;quot; value=&amp;quot;NHibernate.Spatial.Dialect.SomeSpatialDialect,NHibernate.Spatial&amp;quot; /&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;Replace &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SomeSpatialDialect&lt;/span&gt;&lt;/span&gt; by the spatial dialect to be used. For example, &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;MsSqlSpatialDialect&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;
&lt;h4&gt;Schema Generation Configuration: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Declarative:&lt;/b&gt; Use of &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-database-object" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;&amp;lt;database-object&amp;gt;&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; element is not supported. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Programmatic:&lt;/b&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;    Configuration cfg = new Configuration();
    // Your configuration code (eg. cfg.Configure(); )
    cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;Then you can use a &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/toolsetguide.html#toolsetguide-s1-3" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;SchemaExport&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; object or the &lt;a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-optional" class="externalLink"&gt;hibernate.hbm2ddl.auto&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; configuration property for schema generation.&lt;br /&gt;
&lt;h4&gt;Metadata Mappings Configuration: &lt;/h4&gt;
There are two classes available for metadata mapping in the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Metadata&lt;/span&gt;&lt;/span&gt; namespace: &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeometryColumn&lt;/span&gt;&lt;/span&gt; and &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SpatialReferenceSystem&lt;/span&gt;&lt;/span&gt;. You can add them selectively:&lt;br /&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;Configuration cfg = new Configuration();
// Your configuration code (eg. cfg.Configure(); )
Metadata.AddMapping(cfg, MetadataClass.GeometryColumn);
Metadata.AddMapping(cfg, MetadataClass.SpatialReferenceSystem);
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;Then you can use them as normal mapped classes. For example, you could execute the following HQL query:&lt;br /&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;select srs.WellKnownText from SpatialReferenceSystem as srs where srs.SRID=4326
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;WARNING:&lt;/b&gt; DO NOT add metadata class mappings when using the &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;SchemaExport&lt;/span&gt;&lt;/span&gt; utility. You could lose all contents of metadata tables.&lt;br /&gt;
&lt;h4&gt;NHibernate Mapping: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;In the XML mappings file, map all properties as usual but for geometry columns use the following entry: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot; type=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot; /&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Optionally, for schema generation and default values setting, you can use type parameters. The available parameters are &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;srid&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; and &lt;b&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;subtype&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;. For example: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;&amp;lt;property name=&amp;quot;Geometry&amp;quot; column=&amp;quot;the_geom&amp;quot;&amp;gt;
    &amp;lt;type name=&amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;&amp;gt;
        &amp;lt;param name=&amp;quot;srid&amp;quot;&amp;gt;4326&amp;lt;/param&amp;gt;
        &amp;lt;param name=&amp;quot;subtype&amp;quot;&amp;gt;POLYGON&amp;lt;/param&amp;gt;
    &amp;lt;/type&amp;gt;
&amp;lt;/property&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;In the mapped class, declare the corresponding property: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;ActiveRecord Mapping: &lt;/h4&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style="font-family:courier new,courier;"&gt;private GeoAPI.Geometries.IGeometry _geometry; 
         
[Property(&amp;quot;the_geom&amp;quot;, ColumnType = &amp;quot;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&amp;quot;)]
public virtual GeoAPI.Geometries.IGeometry Geometry
{
	get
	{
		return this._geometry;
	}
	set
	{
		this._geometry = value;
	}
}
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord.&lt;br /&gt;
&lt;h4&gt;ActiveWriter Mapping: &lt;/h4&gt;
&lt;a href="http://www.altinoren.com/activewriter/" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;ActiveWriter&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; is a tool to visually model entities and relationships, and generate ActiveRecord classes or NHibernate mapping files. Since &lt;a href="http://www.altinoren.com/activewriter/downloads.htm" class="externalLink"&gt;Preview 3&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt;, it supports custom types, so we can use the GeometryType / IGeometry pair..&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example usage:&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Drag &amp;amp; drop a MsSqlSpatial table from Server Explorer/Data connections. &lt;/li&gt;
&lt;li&gt;In the model, select &amp;quot;the_geom&amp;quot; property. &lt;/li&gt;
&lt;li&gt;In the properties window, enter the following values: &lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&amp;lt;tbody&amp;gt;
&lt;tr&gt;
&lt;th&gt;Property &lt;/th&gt;&lt;th&gt;Value &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Column Type &lt;/td&gt;
&lt;td&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Custom&lt;/span&gt;&lt;/span&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom Column Type &lt;/td&gt;
&lt;td&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;NHibernate.Spatial.Type.GeometryType, NHibernate.Spatial&lt;/span&gt;&lt;/span&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom Member Type &lt;/td&gt;
&lt;td&gt;&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;GeoAPI.Geometries.IGeometry&lt;/span&gt;&lt;/span&gt; &lt;/td&gt;
&lt;/tr&gt;
&amp;lt;/tbody&amp;gt;
&lt;/table&gt;
&lt;br /&gt;&lt;b&gt;NOTE:&lt;/b&gt; Type parameters (see &lt;b&gt;NHibernate mapping&lt;/b&gt; above) are not supported in ActiveRecord, so it is in ActiveWriter.&lt;br /&gt;&lt;/div&gt;</description></item><item><title>Sample usage</title><link>http://nhforge.org/wikis/spatial/sample-usage/revision/0.aspx</link><pubDate>Wed, 01 Oct 2008 17:37:00 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:39</guid><dc:creator>Ricardo Stuven</dc:creator><description>Current revision posted to Spatial by Ricardo Stuven on 01/10/2008 02:37:00 p.m.&lt;br /&gt;
&lt;h2&gt;Sample usage&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Find a country by coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = session.CreateCriteria(typeof(Country))
    .Add(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
    .UniqueResult() as Country;&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = Country.FindOne(
    SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Find all the towns in a bounding box, except the one located at some coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;IList towns = session.CreateCriteria(typeof(Town))
    .Add(SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)))
    .Add(Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))))
    .List();&lt;/pre&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Town[] towns = Town.FindAll(
    SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)),
    Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The previous example just shows how to combine a spatial criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Contains&lt;/span&gt;&lt;/span&gt;) with a normal criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Not&lt;/span&gt;&lt;/span&gt;), but in this case we could use simply &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Disjoint&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h4&gt;Get states boundaries grouping counties by state: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;ProjectionQuery&amp;lt;County&amp;gt; query = new ProjectionQuery&amp;lt;County&amp;gt;(
    Projections.ProjectionList()
        .Add(Projections.GroupProperty(&amp;quot;State&amp;quot;))
        .Add(SpatialProjections.Union(&amp;quot;Boundaries&amp;quot;))
    );
IList&amp;lt;object[]&amp;gt; stateBoundaries= query.Execute();&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For people with a GIS backgroud, the &amp;quot;projection&amp;quot; term could be confusing. In this context, it has nothing to do with cartographic projections. It&amp;#39;s rather a term borrowed from &lt;a class="externalLink" href="http://en.wikipedia.org/wiki/Projection_(relational_algebra)"&gt;&lt;span style="color:#3e62a6;"&gt;relational algebra&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Create a new vehicle GPS position: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;public void TrackVehicule(Vehicle vehicule, double longitude, double latitude, DateTime when)
{
    Tracking tracking = new Tracking();
    tracking.Vehicle = vehicle;
    tracking.Position = new Point(longitude, latitude);
    tracking.When = when;
    session.Save(tracking);
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;More, please! &lt;/h4&gt;
&lt;p&gt;You also will find lots of sample usage code in the tests project (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Tests.NHibernate.Spatial&lt;/span&gt;&lt;/span&gt;). Check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/trunk/src/NHibernate.Spatial/src/Tests.NHibernate.Spatial/CriteriaFixture.cs?view=markup"&gt;CriteriaFixture.cs&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/trunk/src/NHibernate.Spatial/src/Tests.NHibernate.Spatial/ProjectionsFixture.cs?view=markup"&gt;ProjectionsFixture.cs&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/trunk/src/NHibernate.Spatial/src/Tests.NHibernate.Spatial/OgcSfSql11Compliance/ConformanceItemsFixture.cs?view=markup"&gt;OgcSfSql11Compliance/ConformanceItemsFixture.cs&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/trunk/src/NHibernate.Spatial/src/Tests.NHibernate.Spatial/RandomGeometries/SpatialQueriesFixture.cs?view=markup"&gt;RandomGeometries/SpatialQueriesFixture.cs&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Sample usage</title><link>http://nhforge.org/wikis/spatial/sample-usage/revision/3.aspx</link><pubDate>Wed, 01 Oct 2008 01:22:23 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:163</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 3 posted to Spatial by Ricardo Stuven on 30/09/2008 10:22:23 p.m.&lt;br /&gt;
&lt;h2&gt;Sample usage&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Find a country by coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = session.CreateCriteria(typeof(Country))
    .Add(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
    .UniqueResult() as Country;&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = Country.FindOne(
    SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Find all the towns in a bounding box, except the one located at some coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;IList towns = session.CreateCriteria(typeof(Town))
    .Add(SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)))
    .Add(Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))))
    .List();&lt;/pre&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Town[] towns = Town.FindAll(
    SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)),
    Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The previous example just shows how to combine a spatial criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Contains&lt;/span&gt;&lt;/span&gt;) with a normal criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Not&lt;/span&gt;&lt;/span&gt;), but in this case we could use simply &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Disjoint&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h4&gt;Get states boundaries grouping counties by state: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;ProjectionQuery&amp;lt;County&amp;gt; query = new ProjectionQuery&amp;lt;County&amp;gt;(
    Projections.ProjectionList()
        .Add(Projections.GroupProperty(&amp;quot;State&amp;quot;))
        .Add(SpatialProjections.Union(&amp;quot;Boundaries&amp;quot;))
    );
IList&amp;lt;object[]&amp;gt; stateBoundaries= query.Execute();&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For people with a GIS backgroud, the &amp;quot;projection&amp;quot; term could be confusing. In this context, it has nothing to do with cartographic projections. It&amp;#39;s rather a term borrowed from &lt;a href="http://en.wikipedia.org/wiki/Projection_(relational_algebra)" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;relational algebra&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Create a new vehicle GPS position: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;public void TrackVehicule(Vehicle vehicule, double longitude, double latitude, DateTime when)
{
    Tracking tracking = new Tracking();
    tracking.Vehicle = vehicle;
    tracking.Position = new Point(longitude, latitude);
    tracking.When = when;
    session.Save(tracking);
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;More, please! &lt;/h4&gt;
&lt;p&gt;You also will find lots of sample usage code in the tests project (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Tests.NHibernate.Spatial&lt;/span&gt;&lt;/span&gt;). Check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CriteriaFixture.cs&lt;/li&gt;
&lt;li&gt;ProjectionsFixture.cs&lt;/li&gt;
&lt;li&gt;OgcSfSql11Compliance/ConformanceItemsFixture.cs&lt;/li&gt;
&lt;li&gt;RandomGeometries/SpatialQueriesFixture.cs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Sample usage</title><link>http://nhforge.org/wikis/spatial/sample-usage/revision/2.aspx</link><pubDate>Wed, 01 Oct 2008 01:17:22 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:161</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 2 posted to Spatial by Ricardo Stuven on 30/09/2008 10:17:22 p.m.&lt;br /&gt;
&lt;h2&gt;Sample usage&lt;/h2&gt;
&lt;h4 class="wikidoc"&gt;Find a country by coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = session.CreateCriteria(typeof(Country))
    .Add(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
    .UniqueResult() as Country;&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = Country.FindOne(
    SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Find all the towns in a bounding box, except the one located at some coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;IList towns = session.CreateCriteria(typeof(Town))
    .Add(SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)))
    .Add(Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))))
    .List();&lt;/pre&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Town[] towns = Town.FindAll(
    SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)),
    Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;br /&gt;The previous example just shows how to combine a spatial criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Contains&lt;/span&gt;&lt;/span&gt;) with a normal criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Not&lt;/span&gt;&lt;/span&gt;), but in this case we could use simply &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Disjoint&lt;/span&gt;&lt;/span&gt;.&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h4&gt;Get states boundaries grouping counties by state: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;ProjectionQuery&amp;lt;County&amp;gt; query = new ProjectionQuery&amp;lt;County&amp;gt;(
    Projections.ProjectionList()
        .Add(Projections.GroupProperty(&amp;quot;State&amp;quot;))
        .Add(SpatialProjections.Union(&amp;quot;Boundaries&amp;quot;))
    );
IList&amp;lt;object[]&amp;gt; stateBoundaries= query.Execute();&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For people with a GIS backgroud, the &amp;quot;projection&amp;quot; term could be confusing. In this context, it has nothing to do with cartographic projections. It&amp;#39;s rather a term borrowed from &lt;a class="externalLink" href="http://en.wikipedia.org/wiki/Projection_(relational_algebra)"&gt;&lt;span style="color:#3e62a6;"&gt;relational algebra&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Create a new vehicle GPS position: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;public void TrackVehicule(Vehicle vehicule, double longitude, double latitude, DateTime when)
{
    Tracking tracking = new Tracking();
    tracking.Vehicle = vehicle;
    tracking.Position = new Point(longitude, latitude);
    tracking.When = when;
    session.Save(tracking);
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;More, please! &lt;/h4&gt;
&lt;p&gt;You also will find lots of sample usage code in the tests project (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Tests.NHibernate.Spatial&lt;/span&gt;&lt;/span&gt;). Check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CriteriaFixture.cs&lt;/li&gt;
&lt;li&gt;ProjectionsFixture.cs&lt;/li&gt;
&lt;li&gt;OgcSfSql11Compliance/ConformanceItemsFixture.cs&lt;/li&gt;
&lt;li&gt;RandomGeometries/SpatialQueriesFixture.cs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Sample usage</title><link>http://nhforge.org/wikis/spatial/sample-usage/revision/1.aspx</link><pubDate>Fri, 26 Sep 2008 21:35:40 GMT</pubDate><guid isPermaLink="false">45f813f2-f1c4-4eda-a619-288e3cadc793:160</guid><dc:creator>Ricardo Stuven</dc:creator><description>Revision 1 posted to Spatial by Ricardo Stuven on 26/09/2008 06:35:40 p.m.&lt;br /&gt;
&lt;h4 class="wikidoc"&gt;Find a country by coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = session.CreateCriteria(typeof(Country))
    .Add(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
    .UniqueResult() as Country;&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Country country = Country.FindOne(
    SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Find all the towns in a bounding box, except the one located at some coordinates: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;IList towns = session.CreateCriteria(typeof(Town))
    .Add(SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)))
    .Add(Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24))))
    .List();&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;
&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;Town[] towns = Town.FindAll(
    SpatialExpression.Filter(&amp;quot;Boundaries&amp;quot;, new Envelope(-70, -68, -32, -34)),
    Expression.Not(SpatialExpression.Contains(&amp;quot;Boundaries&amp;quot;, new Point(-70.40, -33.24)))
);&lt;/pre&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;br /&gt;The previous example just shows how to combine a spatial criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Contains&lt;/span&gt;&lt;/span&gt;) with a normal criterion (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Not&lt;/span&gt;&lt;/span&gt;), but in this case we could use simply &lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Disjoint&lt;/span&gt;&lt;/span&gt;.&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h4&gt;Get states boundaries grouping counties by state: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using ActiveRecord: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;ProjectionQuery&amp;lt;County&amp;gt; query = new ProjectionQuery&amp;lt;County&amp;gt;(
    Projections.ProjectionList()
        .Add(Projections.GroupProperty(&amp;quot;State&amp;quot;))
        .Add(SpatialProjections.Union(&amp;quot;Boundaries&amp;quot;))
    );
IList&amp;lt;object[]&amp;gt; stateBoundaries= query.Execute();&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; For people with a GIS backgroud, the &amp;quot;projection&amp;quot; term could be confusing. In this context, it has nothing to do with cartographic projections. It&amp;#39;s rather a term borrowed from &lt;a href="http://en.wikipedia.org/wiki/Projection_(relational_algebra)" class="externalLink"&gt;&lt;span style="color:#3e62a6;"&gt;relational algebra&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Create a new vehicle GPS position: &lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Using NHibernate: &lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;text-transform:none;color:#000000;text-indent:0px;font-family:&amp;#39;Segoe UI&amp;#39;;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;pre style="margin-top:0px;overflow-y:hidden;font-size:1em;overflow-x:auto;font-family:&amp;#39;Courier New&amp;#39;;height:auto;background-color:#ececec;border:#3e62a6 0.1em dashed;padding:0.5em;"&gt;public void TrackVehicule(Vehicle vehicule, double longitude, double latitude, DateTime when)
{
    Tracking tracking = new Tracking();
    tracking.Vehicle = vehicle;
    tracking.Position = new Point(longitude, latitude);
    tracking.When = when;
    session.Save(tracking);
}&lt;/pre&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;More, please! &lt;/h4&gt;
&lt;p&gt;You also will find lots of sample usage code in the tests project (&lt;span class="codeInline"&gt;&lt;span style="font-family:Courier New;"&gt;Tests.NHibernate.Spatial&lt;/span&gt;&lt;/span&gt;). Check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CriteriaFixture.cs&lt;/li&gt;
&lt;li&gt;ProjectionsFixture.cs&lt;/li&gt;
&lt;li&gt;OgcSfSql11Compliance/ConformanceItemsFixture.cs&lt;/li&gt;
&lt;li&gt;RandomGeometries/SpatialQueriesFixture.cs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>