title: How can I read from a DataRow or a DataReader using the same code?
body: <p>Currently, I am using a <code>SqlDataReader</code> loaded up with a simple database 'Select' query. Each row represents a domain object, so I inflate each object like this:</p>
  
  <pre><code>Dim loadedItems As New List(Of Item)
  Dim dr As SqlDataReader = GetItemsDataReader()
  While dr.Read()
    Dim item As Item = GetItemFromData(dr)
    loadedItems.Add(item)
  End While
  </code></pre>
  
  <p>The <code>GetItemFromData</code> method I wrote looks something like this:</p>
  
  <pre><code>Private Function GetItemFromData(dr As SqlDataReader) As Item
    Dim loadedItem As New Item()
    loadedItem.ID = dr("ID")
    loadedItem.Name = dr("Name")
    'etc., etc.'
    Return loadedItem
  End Function
  </code></pre>
  
  <p>In some cases, I have to read data from a <code>DataRow</code> instead of a <code>SqlDataReader</code>. But the code would be the exact same! As I look at my <code>GetItemFromData</code> method, I want to accept a more generic type of object in the <code>dr</code> parameter so that I can treat a <code>DataReader</code> the same as a <code>DataRow</code>, since I would be writing the exact same code inside the method if I wrote one that was meant to use a <code>DataRow</code>. Is there a way to do that?</p>