Issues with the <[Else]> directive

Posts   
 
    
LukeO
User
Posts: 58
Joined: 23-Jul-2007
# Posted on: 22-Aug-2008 23:56:43   

I've been playing with templates again.

I'm trying to make a template to make a DTO for a typed view.

Here is a snippet of the template:

public virtual <[If IsNullable]>Nullable<<[TypeOfTypedViewField]>><[Else]><[TypeOfTypedViewField]><[EndIf]> <[TypedViewFieldName]>

And an example of what this will generate:

public virtual Nullable<System.String>System.String PrimaryPhone

As you can see it is adding System.String twice. Maybe I've been staring at this too long but I can't seem to see what is wrong beside the <[Else]> directive being ignored.

Any thoughts? -Luke

Oh... I'm using v2.6.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Aug-2008 07:08:19   

Could you please attach the whole template?

David Elizondo | LLBLGen Support Team
LukeO
User
Posts: 58
Joined: 23-Jul-2007
# Posted on: 25-Aug-2008 19:43:07   

daelmo wrote:

Could you please attach the whole template?

Here it is.

Attachments
Filename File size Added on Approval
viewDataTransferObject.template 2,983 25-Aug-2008 19:44.04 Approved
LukeO
User
Posts: 58
Joined: 23-Jul-2007
# Posted on: 25-Aug-2008 20:10:59   

My new thinking is that the IsNullable only works on entity fields and not if type view fields. Interestingly I tried this:

public virtual <[If IsNullable]>Nullable<<[TypeOfTypedViewField]>><[EndIf]><[If Not IsNullable]><[TypeOfTypedViewField]><[EndIf]><[TypedViewFieldName]> And got the same results.

LukeO wrote:

daelmo wrote:

Could you please attach the whole template?

Here it is.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 25-Aug-2008 20:41:55   

It indeed only works on entity fields, because view fields are always nullable: the target field is always set to be nullable so the if statement isn't required, it will always be true.

Frans Bouma | Lead developer LLBLGen Pro