title: LINQ Unpivot a list
body: <p>I have a table which spreads weekly values into 52 columns, together with Product and Location columns.
  E.g. </p>
  
  <pre><code>Product|WK-0|WK-1|WK-2|...|WK-52|Location
  </code></pre>
  
  <p>I'm trying to transpose this table into row as such :</p>
  
  <pre><code>Product|Location|Week|Value
  </code></pre>
  
  <p>Based on <a href="https://stackoverflow.com/a/11641690/2699762" title="example">example</a>, I created following code :</p>
  
  <pre><code>var columns = 53;
  var testList =from n in Enumerable.Range(1, columns)
                let c = db.Stock_On_Hand_Files
                          .Where(p =&gt; p.Product == "00009E85 " &amp;&amp; p.Location == "A_DOMEST")
                          .First()
                select new
                {
                  Product = c.Product,
                  Location = c.Location,
                  Column = n.ToString(),
                  SOH = c[n]
                 };
  </code></pre>
  
  <p>But I'm getting following error on the last line</p>
  
  <blockquote>
    <p>Error  CS0021  Cannot apply indexing with [] to an expression of type 'Stock_On_Hand_File'</p>
  </blockquote>
  
  <p>As requested, schema for Stock On Hand File.</p>
  
  <pre><code>    public partial class Stock_On_Hand_File
  {
      public string Product { get; set; }
      public Nullable&lt;double&gt; PastDue { get; set; }
      public Nullable&lt;double&gt; WK_001 { get; set; }
      public Nullable&lt;double&gt; WK_002 { get; set; }
      public Nullable&lt;double&gt; WK_003 { get; set; }
      public Nullable&lt;double&gt; WK_004 { get; set; }
      public Nullable&lt;double&gt; WK_005 { get; set; }
      public Nullable&lt;double&gt; WK_006 { get; set; }
      public Nullable&lt;double&gt; WK_007 { get; set; }
      public Nullable&lt;double&gt; WK_008 { get; set; }
      public Nullable&lt;double&gt; WK_009 { get; set; }
      public Nullable&lt;double&gt; WK_010 { get; set; }
      public Nullable&lt;double&gt; WK_011 { get; set; }
      public Nullable&lt;double&gt; WK_012 { get; set; }
      public Nullable&lt;double&gt; WK_013 { get; set; }
      public Nullable&lt;double&gt; WK_014 { get; set; }
      public Nullable&lt;double&gt; WK_015 { get; set; }
      public Nullable&lt;double&gt; WK_016 { get; set; }
      public Nullable&lt;double&gt; WK_017 { get; set; }
      public Nullable&lt;double&gt; WK_018 { get; set; }
      public Nullable&lt;double&gt; WK_019 { get; set; }
      public Nullable&lt;double&gt; WK_020 { get; set; }
      public Nullable&lt;double&gt; WK_021 { get; set; }
      public Nullable&lt;double&gt; WK_022 { get; set; }
      public Nullable&lt;double&gt; WK_023 { get; set; }
      public Nullable&lt;double&gt; WK_024 { get; set; }
      public Nullable&lt;double&gt; WK_025 { get; set; }
      public Nullable&lt;double&gt; WK_026 { get; set; }
      public Nullable&lt;double&gt; WK_027 { get; set; }
      public Nullable&lt;double&gt; WK_028 { get; set; }
      public Nullable&lt;double&gt; WK_029 { get; set; }
      public Nullable&lt;double&gt; WK_030 { get; set; }
      public Nullable&lt;double&gt; WK_031 { get; set; }
      public Nullable&lt;double&gt; WK_032 { get; set; }
      public Nullable&lt;double&gt; WK_033 { get; set; }
      public Nullable&lt;double&gt; WK_034 { get; set; }
      public Nullable&lt;double&gt; WK_035 { get; set; }
      public Nullable&lt;double&gt; WK_036 { get; set; }
      public Nullable&lt;double&gt; WK_037 { get; set; }
      public Nullable&lt;double&gt; WK_038 { get; set; }
      public Nullable&lt;double&gt; WK_039 { get; set; }
      public Nullable&lt;double&gt; WK_040 { get; set; }
      public Nullable&lt;double&gt; WK_041 { get; set; }
      public Nullable&lt;double&gt; WK_042 { get; set; }
      public Nullable&lt;double&gt; WK_043 { get; set; }
      public Nullable&lt;double&gt; WK_044 { get; set; }
      public Nullable&lt;double&gt; WK_045 { get; set; }
      public Nullable&lt;double&gt; WK_046 { get; set; }
      public Nullable&lt;double&gt; WK_047 { get; set; }
      public Nullable&lt;double&gt; WK_048 { get; set; }
      public Nullable&lt;double&gt; WK_049 { get; set; }
      public Nullable&lt;double&gt; WK_050 { get; set; }
      public Nullable&lt;double&gt; WK_051 { get; set; }
      public Nullable&lt;double&gt; WK_052 { get; set; }
      public string Location { get; set; }
      public Nullable&lt;System.DateTime&gt; UpdateDate { get; set; }
  }
  </code></pre>