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

蓝咒 提交于 2019-12-06 07:36:36

问题


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.

Here's the error: UdtTypeName property must be set for UDT parameters

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

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

Here's the important bits of the table:

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

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.


回答1:


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



来源:https://stackoverflow.com/questions/5644466/updating-sql-server-2008-records-w-spatial-data-types-via-massive-orm-executen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!