title: Using Microsoft T4 to create data access classes
body: <p>I'm new to T4 but I have stumbled accross it and it looks very useful.</p>
  
  <p>I'm trying to generate some simple DA classes and need some advice one a particular part of my code.</p>
  
  <p>How can i generate the following code given that I already have the table name and column names (in this case table "<em>Agreements</em>" and columns "<em>AgreementId</em>", "<em>ContactId</em>", etc)?</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>The -1 figure is the default value and the cause the condition to fail.</p>
  
  <p>The ordinals are simply static integer values refering to a location in some DataReader results. They are set using the SetOrdinals(DataReader reader) method.</p>
  
  <p>Thanks
  Anthony</p>