NHibernate空间KeyNotFoundException

时间:2015-04-18 08:26:19

标签: c# nhibernate spatial

我正在尝试映射NHibernate.Spatial.Type.MsSql2008GeographyType,NHibernate.Spatial.MsSql

我的映射文件如下:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
  <class name="GPSPosition" table="GPSPosition" >
    <id name="Id" column="id" type="Int64" access="nosetter.camelcase" unsaved-value="0">
      <generator class="identity" />
    </id>       
    <property name="GPSPoint" column="gps_point">
        <type name="NHibernate.Spatial.Type.MsSql2008GeographyType,NHibernate.Spatial.MsSql">
            <param name="srid">4326</param>
        </type>
    </property>
  </class>
</hibernate-mapping>

我使用public GeoAPI.Geometries.IGeometry GPSPoint { get; set; }属性。

当我尝试Configuration.BuildSessionFactory()时,我得到例外:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   v System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   v NHibernate.Spatial.Type.GeometryTypeBase`1.SetParameterValues(IDictionary`2 parameters)
   v NHibernate.Type.TypeFactory.InjectParameters(Object type, IDictionary`2 parameters)
   v NHibernate.Type.CustomType..ctor(Type userTypeClass, IDictionary`2 parameters)
   v NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters, Nullable`1 length)
   v NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters)
   v NHibernate.Mapping.SimpleValue.GetHeuristicType()
   v NHibernate.Mapping.SimpleValue.get_Type()
   v NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping)
   v NHibernate.Mapping.Property.IsValid(IMapping mapping)
   v NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
   v NHibernate.Mapping.RootClass.Validate(IMapping mapping)
   v NHibernate.Cfg.Configuration.ValidateEntities()
   v NHibernate.Cfg.Configuration.Validate()
   v NHibernate.Cfg.Configuration.BuildSessionFactory()

异常是由于Type已注册?当我选择NHibernate属性

var pr = Configuration.ClassMappings.First(f => f.EntityName == "GPSPosition").GetProperty("GPSPoint")

然后pr.Type引发此异常KeyNotFoundException

帮助我找不到的东西。

0 个答案:

没有答案