FluentNHibernate set default column value for a bool

Go To StackoverFlow.com

4

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.

2009-06-16 08:29
by diadiora


5

Have you tried something like this

 this.Map(x => x.SomeBitColumn)
     .Access.Property()
     .Default("1");
2009-10-14 20:37
by Nikola Malovic


0

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.

2009-06-16 08:45
by dove
No I do not want to use NHibernate Validators, I just want to generate a table schema where for the BIT type of column I can set the default value of '1' - diadiora 2009-06-16 08:57
@diadiora out of interest, have you a particular objection to NHV? they would most likely you let you do just what you seek, are quite light weight and could be used solely your schema generation. Why reinvent the wheel on this one, or maybe I'm missing something here - dove 2009-06-16 10:32