通过 Massive ORM (ExecuteNonQuery) 更新带有空间数据类型的 SQL Server 2008 记录,UdtTypeName 错误
我正在尝试使用 Rob Conery 的 Massive“动态 ORM”来查询我的数据库(到目前为止效果很好)。当我向表中添加地理字段时遇到了问题。
错误如下: 必须为 UDT 参数设置 UdtTypeName 属性
更新 (2011 年 4 月 14 日): 引发异常的 ADO 方法是 .ExecuteNonQuery();
这里是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;
}
抛出异常的具体行是: result += cmd.ExecuteNonQuery();
这是表中的重要部分:
- PlaceId - bigint PK
- Name - nvarchar
- GeoLocation(地理类型 - 作为点)
- ...
很难找到其他使用 Massive 的人,但我确实在 Massive 的 GitHub 问题选项卡。您可以此处查看 Massive 源代码。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定如何最好地将其集成到 Massive 中,但基本上您需要完全按照错误所述进行操作:
基本上 SQL Server 需要您为“奇怪”参数显式命名 UdtTypeName:
http://devlicio.us/blogs/sergio_pereira /archive/2008/06/11/udttypename-and-net-data-types-in-sql.aspx
I'm not sure how best to integrate this into Massive, but basically you need to do exactly what the error says:
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