Folks,
I'd like to create some T4 templates for generating class files (about 7 per table) from a database to support our in-house ORM (don't ask - long story and historical reasons.....)
What I'd really love to do is have a property on my main TT template to visually pick server, database and table for which to create the files (something like the table picker in CodeSmith).
Since that doesn't seem to exist (or does it?), I figured next best thing is using three string property for server, database, table name, and use SMO to connect to that table and get the column data I need.
I tried to follow Oleg Sych's examples, and came up with:
<#@ property name="serverName" processor="PropertyProcessor" type="System.String" #>
<#@ property name="databaseName" processor="PropertyProcessor" type="System.String" #>
<#@ property name="tableName" processor="PropertyProcessor" type="System.String" #>
but then how do I reference those properties in my code block which connects to the server specified using SMO to retrieve the data?
<#
Server server = new Server();
Database database = new Database(server, "DASECO_DEV");
Table table = new Table(database, "T_User");
table.Refresh();
#>
I tried putting a <#= serverName #>
inside the brackets of the Server() constructor - but that doesn't work :-( Seems like I'm a bit stuck here...... what's the point of having properties if I can't evaluate and use their values! :-)
Any takers??
Marc