views:

129

answers:

2

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.

A: 

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.

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
@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
+1  A: 

Have you tried something like this

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