更新SQL Server 2008中记录W¯¯通过大规模的ORM(的ExecuteNonQuery)/空间数据类型,UdtTypeName错误 [英] Updating SQL Server 2008 records w/spatial data types via Massive ORM (ExecuteNonQuery), UdtTypeName error

查看:390
本文介绍了更新SQL Server 2008中记录W¯¯通过大规模的ORM(的ExecuteNonQuery)/空间数据类型,UdtTypeName错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用大规模动态ORM的罗布科纳查询我的DB(伟大的工作,到目前为止)。 。遇到了一个问题,当我添加了一个地理领域我的表

I'm trying to use Massive "dynamic ORM" by Rob Conery to query my DB (working GREAT so far). Ran into a problem when I added a Geography field to my tables.

这里的错误:
UdtTypeName属性必须为UDT参数进行设置

更新(14Apr2011):即抛出异常的ADO方法为 .ExecuteNonQuery(); 下面是Massive.cs抛出异常的方法:

Update (14Apr2011): The ADO method that is throwing the exception is .ExecuteNonQuery(); Here's the method from Massive.cs that throws the exception:

    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;
    }

这将引发它的具体线路:结果+ = cmd.ExecuteNonQuery();

The specific line that throws it is: result += cmd.ExecuteNonQuery();

这里的表的重要位:


  • PlaceId - BIGINT PK

  • 名称 - 为nvarchar

  • GeoLocation中(地理类型 - 作为一个点)

  • ...

  • PlaceId - bigint PK
  • Name - nvarchar
  • GeoLocation (Geography type - as a Point)
  • ...

这是很难找到任何人有使用声势浩大,但我确实在 Massive的GitHub的问题标签报告错误。您可以查看源代码的海量这里

It's hard to find any others out there using Massive, but I did report the error on Massive's GitHub Issues tab. You can view the source code for Massive here.

推荐答案

我不知道如何以最佳方式这个集成到大规模,但基本上你需要做的完全错误这样说:

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";



基本上SQL Server需要你明确地命名UdtTypeName为怪异的参数:

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

这篇关于更新SQL Server 2008中记录W¯¯通过大规模的ORM(的ExecuteNonQuery)/空间数据类型,UdtTypeName错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆