如何使用 SQL Server 2005 映射 NHibernate 中的 uint
我的实体有一个 uint 类型的属性。 类似于:
public class Enity
{
public uint Count {get;set;}
}
当我尝试将其持久保存到 SQL Server 2005 数据库中时,出现异常
方言不支持 DbType.UInt32
解决此问题的最简单方法是什么。 例如,我可以将它存储在数据库中很长时间。 我只是不知道如何将其告诉 NHibernate。
I have a property of type uint on my entity. Something like:
public class Enity
{
public uint Count {get;set;}
}
When I try to persist that into the SQL Server 2005 database, I get an exception
Dialect does not support DbType.UInt32
What would be the easiest way to workaround this. I could for example store it as long in the DB.
I only don't know how to tell that to NHibernate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最干净、最官方的解决方案可能是编写一个用户类型。
举个例子,比如 这个并进行调整。 如果您有许多
uint
,那么有一个用户类型是值得的。The cleanest, most official solution would probably be to write a user type.
Take an example, like this one and adapt it. If you have many
uint
's, it is worth to have a user type.还没有尝试过这个,所以不确定这是否适合你,但你可以尝试创建自己的方言并在 web.config/app.config
方言类中注册:
Web.config:
Haven't tried this so not sure if this will work for you but you could try creating your own Dialect and registering that in the web.config/app.config
Dialect class:
Web.config:
您可以尝试添加另一个私有“镜像”属性。
当然,仅如果映射无法解决该问题,则应执行此操作。
You could try to add another private "mirror"-property.
Of course you should do this only if it could not be solved by the mapping.