title: How Do I Read A Rowversion or Timestamp SQL Server Data Type From a SQLDataReader to a C# Variable
body: <p>I have a SQL Server 2012 database. Each table has a set of audit fields. One is a column named RowVer with a datatype of <code>timestamp</code> (same as <code>rowversion</code>).</p>
  
  <p>I'm having difficulty reading the value from a <code>SqlDataReader</code> into a C# object with a property named <code>User.RowVersion</code> with a datatype of <code>Byte[]</code>.</p>
  
  <p>Code Snippet of <code>while (rdr.Read())</code> block</p>
  
  <pre><code>...
  user.DateCreated = rdr.GetDateTime(14);
  user.CreatedByUserId = rdr.GetInt32(15);
  if (!rdr.IsDBNull(16)) { user.DateLastUpdated = rdr.GetDateTime(16); }
  if (!rdr.IsDBNull(17)) { user.LastUpdatedByUserId = rdr.GetInt32(17); }
  user.RowVersion = rdr.???;
  ...
  </code></pre>
  
  <p>The RowVersion value is only used as a comparison for concurrency when updating the database.</p>
  
  <p>This of course is NOT an EF implementation.</p>