title: LINQ to SQL Reflection in Select
body: <p>I've got the following problem. I have table in a SQL database which looks like this:  </p>
  
  <p>| id | attr0 | attr1 | attr2 | attr3 | attr4 | attr5 |</p>
  
  <p>So, I want to get the data from this table in a for loop.</p>
  
  <p>I've created the class
      </p>
  
  <pre><code>public class Attribute{
      public int Id {get; set;}
      public string Description {get; set}
  }
  </code></pre>
  
  <p>And now i want to get all the attributes from table into one list
      </p>
  
  <pre><code>List&lt;Attribute&gt; attributeList = new List&lt;Attribute&gt;();
  for(int i=0; i&lt;6;i++)
  {
      attributeList.Add((from a in db.Attributes
                    select new Attribute{
                        Id = a.Id,
                        Description = a.attr0}).First(); //How to use here i instead a fixed column name?
  }
  </code></pre>
  
  <p>Is it possible to use <code>i</code> and get all attributes with one loop?</p>
  
  <p>I was trying to use reflection but the compiler gives me an error, the code for that was:
  </p>
  
  <pre><code>for(int i=0; i&lt;6;i++)
  {
      attributeList.Add((from a in db.Attributes
                    select new Attribute{
                        Id = a.Id,
                        Description = a.GetType().GetProperty("attr"+i).GetValue(a,null))}).First();
  </code></pre>
  
  <p>UPDATE:
  The error is:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'System.Object GetValue(System.Object, System.Object[])' method, and this method cannot be translated into a store expression.</p>
  </blockquote>