title: How can I populate a class from the results of a SQL query in C#?
body: <p>I've got a class like this:</p>
  
  <pre><code>public class Product
  {
      public int ProductId { get; private set; }
      public int SupplierId { get; private set; }
  
      public string Name { get; private set; }
      public decimal Price { get; private set; }
      public int Stock { get; private set; }
      public int PendingStock { get; private set; }
  }
  </code></pre>
  
  <p>I can fetch those details from my database like this:</p>
  
  <pre><code>SELECT product_id, supplier_id, name, price, total_stock, pending_stock 
  FROM products
  WHERE product_id = ?
  </code></pre>
  
  <p>I don't want to have to manually run through a <code>DataSet</code> or <code>DataTable</code> to set the values.</p>
  
  <p>I'm sure there's a way to populate the class using some kind of binding / mapping mechanism, but the only stuff I could find was for binding to winforms components or using XAML.</p>
  
  <p>Is there some kind of attribute I can apply to my properties / class to have the class automatically populated from a query row?</p>