NHibernate 空间几何类型变为 NULL 是线仅包含具有相同坐标的两个点
我有这样的类:
public class Edge
{
public virtual Guid IDEdge { get; set; }
public virtual Node Source { get; set; }
public virtual Node Target { get; set; }
public virtual double Length { get; set; }
public virtual byte Car { get; set; }
public virtual byte CarReverse { get; set; }
public virtual IGeometry Geometry { get; set; }
}
...和流畅的映射:
public class EdgeMap : ClassMap<Edge>
{
public EdgeMap()
{
Table("Edges");
LazyLoad();
Id(x => x.IDEdge).GeneratedBy.GuidComb().Column("IDEdge");
References(x => x.Source).Column("Source");
References(x => x.Target).Column("Target");
Map(x => x.Length).Not.Nullable().Column("Length");
Map(x => x.Car).Not.Nullable().Column("Car");
Map(x => x.CarReverse).Not.Nullable().Column("CarReverse");
Map(x => x.Geometry).CustomType<MsSql2008GeometryType>().Not.Nullable().Column("Geom");
}
}
我尝试用几何插入边缘:(
LINESTRING(37.2686 55.739,37.2686 55.739)
具有相同坐标的两个点)
我得到:
not-null property references a null or transient value Edge.Geometry
几何类的某个实例已丢失。如果线包含不同的点,则边缘插入成功。
I have such class:
public class Edge
{
public virtual Guid IDEdge { get; set; }
public virtual Node Source { get; set; }
public virtual Node Target { get; set; }
public virtual double Length { get; set; }
public virtual byte Car { get; set; }
public virtual byte CarReverse { get; set; }
public virtual IGeometry Geometry { get; set; }
}
...and fluent mapping:
public class EdgeMap : ClassMap<Edge>
{
public EdgeMap()
{
Table("Edges");
LazyLoad();
Id(x => x.IDEdge).GeneratedBy.GuidComb().Column("IDEdge");
References(x => x.Source).Column("Source");
References(x => x.Target).Column("Target");
Map(x => x.Length).Not.Nullable().Column("Length");
Map(x => x.Car).Not.Nullable().Column("Car");
Map(x => x.CarReverse).Not.Nullable().Column("CarReverse");
Map(x => x.Geometry).CustomType<MsSql2008GeometryType>().Not.Nullable().Column("Geom");
}
}
I tried to insert edge with geometry:
LINESTRING(37.2686 55.739,37.2686 55.739)
(two points with same coordinates)
I have got:
not-null property references a null or transient value Edge.Geometry
Somewhere instance of Geometry class has been lost. Edge inserts successfully if line contains different points.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQL Server 中有一个限制:LineString 必须至少有两个不同的点。请参阅 http://technet.microsoft.com/en-us/library/bb895372。 NHibernate.Spatial
目前不会针对此类情况抛出适当的异常。
There is a restriction in SQL Server: A LineString must have at least two distinct points. See http://technet.microsoft.com/en-us/library/bb895372.aspx
NHibernate.Spatial currently is not throwing a proper exception for cases like this.