title: Finding data type information for certain objects in DacFx API
body: <p>I'm writing a code generation tool against Sql Server Data Tools and I need to be able to get the data type for:</p>
  
  <ol>
  <li>View Columns</li>
  <li>Computed Columns on a table</li>
  </ol>
  
  <p>Where is this information?  For tables (with the exception of computed columns), it's here:</p>
  
  <pre><code>TSqlObject table;  //retrieved elsewhere
  TSqlObject column = table.GetReferenced(Table.Columns).First(); //first column
  TSqlObject dataType = column.GetReferenced(Column.DataType).FirstOrDefault();
  </code></pre>
  
  <p>For computed columns, <code>dataType</code> above is null.</p>
  
  <p>For views, I've tried:</p>
  
  <pre><code>TSqlObject view;  //retrieved elsewhere
  TSqlObject column = view.GetReferenced(View.Columns).First(); //first column
  TSqlObject dataType = column.GetReferenced(Column.DataType).FirstOrDefault();//null
  </code></pre>
  
  <p>Is this information <em>anywhere</em>?  Are there any other options for getting this information other than publishing the source .DACPAC to a database?</p>
  
  <hr>
  
  <p>EDIT: in response to Ed Elliot below (regarding the use of the strongly-typed DacFx model)</p>
  
  <p>The following code fails to bring back type information for the view:</p>
  
  <pre><code>TSqlTypedModel model = new TSqlTypedModel(@"path.dacpac");
  var view = model.GetObjects&lt;TSqlView&gt;(Microsoft.SqlServer.Dac.Model.DacQueryScopes.UserDefined).FirstOrDefault();
  var viewcolumns = view.Columns;
  
  //false
  bool viewHasTypeInformation = viewcolumns.Any(c =&gt; c.DataType.Count() &gt; 0); 
  
  var table = model.GetObjects&lt;TSqlTable&gt;(Microsoft.SqlServer.Dac.Model.DacQueryScopes.UserDefined).FirstOrDefault();
  var tablecolumns = table.Columns;
  
  //true
  bool tableHasTypeInformation = tablecolumns.Any(c =&gt; c.DataType.Count() &gt; 0);
  </code></pre>
  
  <p>I'm starting to think this is a limitation of the DAC model itself.</p>