Page 1 of 1

Type conversion

Posted: Mon 19 Nov 2012 13:54
by jglowinski
I have a short integer that I want to convert to a boolean (zero = false, non-zero = true). I've written the class SmallIntBoolean which implements NHibernate's IUserType interface to do this. However, when I set the 'Type' property to SmallIntBoolean in the column's property editor the following is generated:

Code: Select all

Map(x => x.IsMainAddress)    
    .Column("PRIMARY_ADDRESS")
    .CustomType("SmallIntBoolean")
    .Access.Property()
    .Generated.Never()
    .CustomSqlType("smallint")
    .Precision(5);
If I were doing it by hand I would do this:

Code: Select all

Map(x => x.IsMainAddress)    
    .Column("PRIMARY_ADDRESS")
    .CustomType<SmallIntBoolean>()
    .Access.Property()
    .Generated.Never()
    .CustomSqlType("smallint")
    .Precision(5);
Also, it creates a target property of type SmallIntBoolean:

Code: Select all

    public virtual SmallIntBoolean IsMainAddress { get/set... }
But I want a boolean:

Code: Select all

    public virtual bool IsMainAddress { get/set... }
How can I do this conversion in Entity Developer?

Thanks.

Re: Type conversion

Posted: Fri 23 Nov 2012 16:34
by Shalex
We consider this behaviour of Entity Developer to be correct.
You should copy standard template(-s) to model folder and modify them correspondingly to implement the code generation you want.