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

后端 未结 5 1608
你的背包
你的背包 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:30

    I know this hardly be useful but in any case. After implementing all lain had said do use in your HQL queries SetParameter third IType parameter. Meaning in

     Hero hero = openSession.Get(3);    
    openSession.CreateQuery(
                  "from Hero h where NHSP.Distance(h.Location,:thislocation)<1000"
                   ).SetParameter("thislocation", hero.Location, new CustomType(typeof(MsSql2008GeographyType), null) ).SetResultTransformer(new DistinctRootEntityResultTransformer())
                   .List();
    

    new CustomType(typeof(MsSql2008GeographyType), null) must be passed or you get your all too famililar "System.ArgumentException: 24204".

    Just spent whole night figuring that one out.

提交回复
热议问题