title: IEnumerable has values but still gives System.NullReferenceException
body: <p>I am populating an <code>IEnumerable</code> using a LINQ query.  The <code>IEnumerable</code> is then passed into another class and appended as a parameter (to a Telerik report).  On this line, I'm getting a <code>System.NullReferenceException</code>.  Through debugging I've confirmed that this <code>IEnumerable</code> has a list of values so I'm not sure why this is happening.</p>
  
  <p>Here are some relevant snippets of my code:</p>
  
  <p><strong>Class1.cs</strong>    </p>
  
  <pre><code>//Note that divisionList is an List of PKs and divisionTotalsList is a list of DivisionTotalsModel
  foreach (int division in divisionList)
              {
  
                  //LINQ Query
                  IEnumerable&lt;DivisionTotalsModel&gt; divSubset =
                      from divno in divisionTotalsList
                      where divno.DivisionNo == division
                      select divno;
  
  
                  //Create Report
                  if(divSubset.Any())
                      Class2.DoStuff(divSubset);
              }
  </code></pre>
  
  <p><strong>Class2.cs</strong></p>
  
  <pre><code>public void DoStuff(IEnumerable&lt;DivisionTotalsModel&gt; divisionList){
       using (var divisionTotalsReport = new DivisionReport())
          {
            //There are other parameters here that are working successfully
            //This is the line that is failing
            divisionTotalsReport.ReportParameters["list"].Value = divisionList;
          }
  }
  </code></pre>
  
  <p>Why is the error occurring here?</p>
  
  <p>The <code>ReportParameters</code> are working with other parameters (<code>DateTime</code> and <code>int</code>), I just didn't include them in the code snippet.</p>
  
  <p>I've tried <code>ToList()</code> and successfully received a <code>List&lt;T&gt;</code>, but Telerik requires an <code>IEnumerable&lt;T&gt;</code>.</p>
  
  <p><strong>The issue has to lie with the new parameter</strong> because I've been able to successfully create the report previously using my other parameters (<code>DateTime</code> and <code>int</code>).  The issue has only started when I've tried to add this new <code>IEnumerable</code> parameter.</p>
  
  <p>I've gone through the debugger and looked at the IEnumerable, it says the base is null but when I go to non public members -> source I can see the items.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>I've figured out the problem, I was attempting to feed the data source as a parameter. I've set it as the data source instead and it works perfectly. </p>