iammaz
iammaz

Reputation: 211

Custom attributes on fields in SubSonic

SubSonic newbe question;

I want to put custom attributes on properties in the generated classes, is that possible?

Upvotes: 2

Views: 191

Answers (2)

Adam Cooper
Adam Cooper

Reputation: 8677

There's two ways to do this:

  • If you want to add them at generation time you can do what Skinniest Man suggests and modify the templates to add them.

  • If you want to add them manually things are a little more tricky and you'll need to create a 'buddy class' and apply your custom attributes to that. You can see an example for data annotations here which should illustrate the concept.

Upvotes: 1

Stephen
Stephen

Reputation: 3621

It's definitely possible. Is this SubSonic 2 or 3? It's doable for either one, but the question of where to find the templates is different depending on which one you're using.

Edit: For SubSonic 2, follow this link and look at the entry on "templateDirectory". For SubSonic 3, you probably have some .tt files in your VS Project you can mess with.

Upvotes: 4

Related Questions