Type conversion

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
jglowinski
Posts: 1
Joined: Mon 19 Nov 2012 13:15

Type conversion

Post by jglowinski » Mon 19 Nov 2012 13:54

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Type conversion

Post by Shalex » Fri 23 Nov 2012 16:34

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.

Post Reply