Adding Attribute to DTO property in Macro

Posts   
 
    
TopDog74
User
Posts: 40
Joined: 27-Apr-2012
# Posted on: 30-Nov-2016 11:45:14   

I am trying to add an Attribute to each of my DTO properties like this:

[Column(Order = 1] public string Prop1 {get; set;}

[Column(Order = 2] public string Prop2 {get; set;}

Is is possible to do this in a macro at project Settings level?

I was trying something like this, but could not figure out if it is possible to access an index value for a field (in the project settings for 'DereivedElementFieldScalar'):

Column(Order = $fieldIndex)

but no joy as of yet. Is there a simple way to achieve this?

Thanks, Iain

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Nov-2016 20:04:38   

I'm not sure if FieldIndex is reliable in this case, because developers can always exclude fields from DTOs. So you would end up with missing indexes.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Dec-2016 18:00:38   

additionally, do you mean the field index of the source field or the index of the field in the derived model element? What is the use case for this macro? Ordering in a bound UI? (to get a picture of why we would add it simple_smile )

There's currently no fieldindex macro.

Frans Bouma | Lead developer LLBLGen Pro