【问题标题】:combining sql server spatial and NHibernate with CreateSqlQuery将 sql server spatial 和 NHibernate 与 CreateSqlQuery 相结合
【发布时间】:2012-11-03 22:16:34
【问题描述】:

我没有在 sql server 2008 中映射地理表,我想在 c# 中使用 nhibernate 用多边形实例查询它。
一开始我尝试直接使用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 中运行此查询时,我得到了预期的结果。

有什么想法或解决方案吗?

谢谢。

【问题讨论】:

    标签: sql-server nhibernate spatial geography


    【解决方案1】:

    问题已解决。我不得不反转多边形的点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      相关资源
      最近更新 更多