I'm new to T4 but I have stumbled accross it and it looks very useful.
I'm trying to generate some simple DA classes and need some advice one a particular part of my code.
How can i generate the following code given that I already have the table name and column names (in this case table "Agreements" and columns "AgreementId", "ContactId", etc)?
if ((ordinal_TableName_ColumnName1 == -1)
|| (ordinal_TableName_ColumnName2 == -1)
|| (ordinal_TableName_ColumnName3 == -1)
|| (ordinal_TableName_ColumnName4 == -1))
// Not interested in below
{
SetOrdianls(reader);
}
while (reader.HasRows())
{
returnCollection.Add(new Entity(reader);
}
The -1 figure is the default value and the cause the condition to fail.
The ordinals are simply static integer values refering to a location in some DataReader results. They are set using the SetOrdinals(DataReader reader) method.
Thanks Anthony