3

我正在尝试使用 Rob Conery 的大规模“动态 ORM”来查询我的数据库(到目前为止工作得很好)。当我向表中添加地理字段时遇到了问题。

这是错误: UdtTypeName property must be set for UDT parameters

更新(2011 年 4 月 14 日):引发异常的 ADO 方法是.ExecuteNonQuery();来自 Massive.cs 的引发异常的方法:

    public virtual int Execute(IEnumerable<DbCommand> commands) {
        var result = 0;
        using (var conn = OpenConnection()) {
            using (var tx = conn.BeginTransaction()) {
                foreach (var cmd in commands) {
                    cmd.Connection = conn;
                    cmd.Transaction = tx;
                    result += cmd.ExecuteNonQuery();
                }
                tx.Commit();
            }
        }
        return result;
    }

抛出它的具体行是:result += cmd.ExecuteNonQuery();

这是表格的重要部分:

  • PlaceId - bigint PK
  • 名称 - nvarchar
  • GeoLocation(地理类型 - 作为一个点)
  • ...

使用 Massive 很难找到其他人,但我确实在Massive 的 GitHub 问题选项卡上报告了错误。您可以在此处查看 Massive 的源代码

4

1 回答 1

9

I'm not sure how best to integrate this into Massive, but basically you need to do exactly what the error says:

yourGeographyParam.UdtTypeName = "Geography";

Basically SQL Server needs you to explicitly name the UdtTypeName for the "weird" parameters:

http://devlicio.us/blogs/sergio_pereira/archive/2008/06/11/udttypename-and-net-data-types-in-sql.aspx

于 2011-04-13T23:43:06.487 回答