简体   繁体   English

通过Massive ORM(ExecuteNonQuery),UdtTypeName错误更新具有空间数据类型的SQL Server 2008记录

[英]Updating SQL Server 2008 records w/spatial data types via Massive ORM (ExecuteNonQuery), UdtTypeName error

I'm trying to use Massive "dynamic ORM" by Rob Conery to query my DB (working GREAT so far). 我正在尝试使用Rob Conery的Massive“动态ORM”来查询我的数据库(到目前为止工作很棒)。 Ran into a problem when I added a Geography field to my tables. 当我将Geography字段添加到表格时出现问题。

Here's the error: UdtTypeName property must be set for UDT parameters 这是错误: UdtTypeName property must be set for UDT parameters

Update (14Apr2011): The ADO method that is throwing the exception is .ExecuteNonQuery(); 更新(14Apr2011):抛出异常的ADO方法是.ExecuteNonQuery(); Here's the method from Massive.cs that throws the exception: 这是抛出异常的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;
    }

The specific line that throws it is: result += cmd.ExecuteNonQuery(); 抛出它的特定行是: result += cmd.ExecuteNonQuery();

Here's the important bits of the table: 这是表格的重要部分:

  • PlaceId - bigint PK PlaceId - bigint PK
  • Name - nvarchar 名称 - nvarchar
  • GeoLocation (Geography type - as a Point) GeoLocation(地理类型 - 作为一个点)
  • ... ...

It's hard to find any others out there using Massive, but I did report the error on Massive's GitHub Issues tab . 使用Massive很难找到其他人,但我确实在Massive的GitHub问题选项卡上报告了错误。 You can view the source code for Massive here . 您可以在此处查看Massive源代码

I'm not sure how best to integrate this into Massive, but basically you need to do exactly what the error says: 我不确定如何最好地将其集成到Massive中,但基本上你需要完成错误所说的内容:

yourGeographyParam.UdtTypeName = "Geography";

Basically SQL Server needs you to explicitly name the UdtTypeName for the "weird" parameters: 基本上SQL Server需要您为“怪异”参数显式命名UdtTypeName:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL Server 2008中的空间数据/地理,OR映射器和C# - Spatial data/Geography in SQL Server 2008, OR mappers and C# SQL Server 2008-创建中的空间MultiLineString问题 - SQL Server 2008 - Spatial MultiLineString problems in creation 在SQL Server中使用用户定义的表类型来更新记录列表 - Using User defined table types in SQL Server for updating list of records System.Data.Spatial DBGeography.Distance()将与SQL Server 2008一起使用吗? - Will System.Data.Spatial DBGeography.Distance() will work with SQL Server 2008? C# 和 SQL Server 插入 ExecuteNonQuery:哪一列导致错误“字符串或二进制数据将被截断?” - C# & SQL Server Insert ExecuteNonQuery: which column is causing the error "String or Binary Data Would Be Truncated?" 在SQL Server 2008数据库中更新映像后出现错误 - Getting error after updating image in Sql server 2008 database c#:SQL Server空间函数:某些记录上的多边形环错误 - c#: SQL Server Spatial Function: Polygon Rings Error on Some Records 什么ADO类型是SQL Server 2008的地理空间类型? - What ADO type is the Geography spatial type from SQL Server 2008? SQL Server错误:ExecuteNonQuery:连接属性尚未初始化 - SQL Server error: ExecuteNonQuery: Connection property has not been initialized 实体框架核心支持SQL空间数据类型 - DBGeography? - Entity Framework Core support for SQL Spatial Data Types - DBGeography?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM