Subsonic 3.0 和 SqlHierachyID
我在 Subsonic 3.0 为包含新 HeirachyID 数据类型的表生成对象时遇到问题。 据我所知,没有相应的.Net类型,并且subsonic似乎不知道如何处理hierachyid数据。
抛出的错误:
“Microsoft.SqlServer.Types.SqlHierarchyId”类型的对象无法转换为“System.String”类型。
代码:
foreach (MyDB.DataAccess.ThingCategory tc in DataAccess.ThingCategory.Find(x => x.fk_Thing.Equals(thingId)))
{
sb.AppendFormat("<{0}>{1}</{0}>", wrapTag, tc.Categories.ToList<DataAccess.Category>()[0].Name);
}
tc.Categories.ToList() 生成错误
或者,我尝试通过编写存储过程以将 hierachyid 列作为字符串返回来解决此问题,并注意到 SubSonic 3.0 存储过程不是强类型的。 或者我做错了什么?
I am having trouble with Subsonic 3.0 generating an object for a table which contains the new HeirachyID datatype. From what I have found, there is no corrosponding .Net type, and subsonic doesn't seem to know how to handle the hierachyid data.
Error that is thrown:
Object of type 'Microsoft.SqlServer.Types.SqlHierarchyId' cannot be converted to type 'System.String'.
Code:
foreach (MyDB.DataAccess.ThingCategory tc in DataAccess.ThingCategory.Find(x => x.fk_Thing.Equals(thingId)))
{
sb.AppendFormat("<{0}>{1}</{0}>", wrapTag, tc.Categories.ToList<DataAccess.Category>()[0].Name);
}
tc.Categories.ToList() generates the error
Alternatively, I tried to get around this by writing a sproc to return the hierachyid column as a string, and noticed SubSonic 3.0 sprocs are not strongly-typed. or am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存储过程可以通过调用 ExecuteTypedList() 进行强类型化
我会在 Github 跟踪器 要么添加对该类型的支持(有人必须贡献这个,因为我认为它不是一个高优先级),要么在它们存在时优雅地处理它。
Sprocs can be strongly-typed by calling ExecuteTypedList()
I would create an issue on the Github tracker to either add support for the type (someone will have to contribute this since I don't think it's a high priority) or to gracefully handle it when they exist.