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:
来源:https://stackoverflow.com/questions/5644466/updating-sql-server-2008-records-w-spatial-data-types-via-massive-orm-executen