NHibernate.Spatial and Sql 2008 Geography type - How to configure

后端 未结 5 1603
你的背包
你的背包 2020-12-13 07:02

I am trying to use Nhibernate with the Sql 2008 Geography type and am having difficulty. I am using Fluent Nhibernate to configure which I am fairly new to so that may be th

5条回答
  •  抹茶落季
    2020-12-13 07:40

    You can create your own factory with a default SRID. For example, you can create a facade for factories such as this:

    public static class Default
    {
        private const int DefaultSrid = 4326;
    
        public static readonly IGeometryFactory Factory;
    
        static Default()
        {
            Factory = new GeometryFactory(new PrecisionModel(), DefaultSrid);
        }
    }
    

    and use it like this:

    var point = Default.Factory.CreatePoint(new Coordinate(10, 10));
    

    instead of using the "new" keyword. You can also use the Default.Factory as a factory method in your IoC framework to create new geometries without the Default facade.

提交回复
热议问题