Hi all,
I am not sure this is proper place to post this topic but if any one can help me then it will be very helpful for me.
I am developing GIS application using ASP.NET 3.5.
The database we are using is Postgresql and NHibernate to store data.
I can store simple data. But I am unable to store data for Geometric field like Box, Polygon etc. using .NET. I have searched on net but not getting good sample code/tutorials.
Can anyone please help and guide me ?
Thanks and Regards
Prasad
Loading
Prasad GodbolePosted Jan 6, 2010, 8:07 AM
Mean while I got 1 solution. Below is sample code.
NHibernate Configuration file code :-
xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="FirstSolution">
<property name="connection.driver_class">NHibernate.Driver.NpgsqlDriverproperty>
<property name="connection.connection_string">Server=localhost;Database=check;User ID=postgres;Password=test#;property>
<property name="dialect">NHibernate.Dialect.PostgreSQLDialectproperty>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castleproperty>
session-factory>
hibernate-configuration>
Class File code :-
public class CustomShapes
{
public virtual int SrNo { get; set; }
public virtual string Name { get; set; }
public virtual string Geometry { get; set; }
}
Mapping File :-
xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="FirstSolution"
namespace="FirstSolution.Domain">
<class name="CustomShapes" table='"database_table_name"'>
<id name="SrNo" type="Int32" column='"SrNo"'>
<generator class="assigned" />
id>
<property name="Name" column='"Name"' type='String'/>
<property name="Geometry" column='"general_geom"' />
class>
hibernate-mapping>
I am storing geometry field as a text in WKT format... and transient object can be saved in persistent state using ISessionFactory interface of NHibernate.
Thanks and Regards
Prasad
AdyPosted Jan 1, 2010, 5:05 PM