简体   繁体   中英

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). 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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM