FluentNHibernate set default column value for a bool

跟風遠走 提交于 2020-06-25 04:09:58

问题


How to set with FluentNHibernate the default value of 1 or 0 for a BIT column of the table generated from my entity for the field of type bool. I think it doesn't matter but in any case the database is sqlserver2005.


回答1:


Have you tried something like this

 this.Map(x => x.SomeBitColumn)
     .Access.Property()
     .Default("1");



回答2:


You probably want to look at using NHibernate Validator for this, here is an ayende example for something close to what you are looking for. They give greater control over what would be created within schema exports as well.



来源:https://stackoverflow.com/questions/1000182/fluentnhibernate-set-default-column-value-for-a-bool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!