Getting Started

Sep 20, 2012 at 3:45 PM

I'm new to T4 and TFDP so please go with this!

I've got a few questions...

  • Is there anywhere that lists the variables/static values that can be put within the <# #> tags?/What can you access from Element. ?
  • For example, instead of iterating through the element/table structure, is there a way to print the whole table definition?
  • Can you retrieve any TFS values such as checkin date or version which could be printed?

Thanks,

Rose

 

Coordinator
Nov 7, 2012 at 2:10 PM

Hi Rose,

it's a bit late but here goes:

The type of the Element property in the template is dependent on what you specify as the generic parameter for the DatabaseTemplate<T> in your T4 template. There is a constraint that T must be of IModelElement (which can be anything like ISqlTable or ISqlProcedure etc) Inside the T4 template you can then access all the properties of that type. (See here as well)

If you want to dump the SQL contents for a table (for example) then you can create a T4 template that uses DatabaseTemplate<ISqlTable> as the base class. ISqlTable also implements the IScriptSourcedModelElement interface through which you can access the underlying script by accessing the PrimarySource property.

To retrieve TFS releated information you should look at the TFS API and just reference that from your T4 template. It's just C# after all. I suggest that you wrap that code into a separate assembly and reference that, it will greatly reduce the clutter in your T4 template.

Hope this helps!