Adding attributes to properties

Posts   
 
    
nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 19-Nov-2010 20:03:30   

Dears at LLBLGen,

I am using version 3.0 Final, October 22nd, 2010. I am generating entity classes from a DB model.

I found out that it is possible to have attributes applied to all properties of a certain kind (NavigatorCollection, etc.) which means that these attributes are always re-applied after every generation. But is it possible, in the designer, to have an attribute applied to a certain property of an entity?

Thank you

Nasser

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Nov-2010 04:57:56   

Hi Nasser,

Sure you can. Just:

  1. Go to entity editor of the involved entity.
  2. Select the "Code gen info" sub tab (below).
  3. Select the "Attributes" sub tab (above)
  4. On the Attribute definition grid, add the desire attribute.

Also, if you added a object type Attribute at Project Properties->Code gen options (for example, Entity attribute), you can edit an entity and select that you don't want that entity inherits that attribute.

For more info read this.

Hope helpful wink

David Elizondo | LLBLGen Support Team
nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 20-Nov-2010 13:03:53   

Dear David!

Thank you for your reply!

The solution you describe would add an attribute to the class definition like


[SomeAttribute()]
public class SomeEntity
{
    int SomeProperty { get; set;}
}


I need to add an Attribute to a property, and have that attribute regenerated every time I generate code from the designer. Somethings like


public class SomeEntity
{
    [SomeAttribute(typeof(int), "SomeString")]
    int SomeProperty { get; set;}
}


Is it possible to define an Attribute per Property in the designer?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Nov-2010 14:33:13   

Yes, just select the field or navigator in the combo box on the tab David mentioned. simple_smile In there you can select to keep the inherited attributes from the project settings and / or add new ones, just for that field.

Frans Bouma | Lead developer LLBLGen Pro
nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 21-Nov-2010 12:00:02   

Thank you for the explanation!