我没有在sql server 2008中映射地理表,我想使用nhibernate在c#中使用多边形实例进行查询。
在开始时我试图直接使用sql server spatial但是遇到了这个问题:
Using SQL Server 2008 Geography types with nHibernate's CreateSQLQuery
我的第二次尝试是这样的:
session.CreateSQLQuery("select [shape] from [table] where (:codeShape).STIntersects([shape]) = 1").SetParameter("codeShape", codeShape, NHibernateUtil.Custom(typeof(MsSql2008GeographyType)));
但是这个尝试也会引发异常:
Could not execute query [select [shape] from [table] where (?).STIntersects([shape]) = 1")] Name:codeShape - Value:POLYGON((30 40, ...))
,内部例外是:
The specified input does not represent a valid geography instance.
尽管codeShape.IsValid仍然返回true。
当我直接在sql server中运行此查询时,我得到了预期的结果。
任何想法或解决方案?
感谢。
答案 0 :(得分:0)
问题解决了。我不得不反转多边形的点。