title: How to pass variable list in ViewBag
body: <p>I am working on a project I just need to grab data from two tables and I want to use LINQ Query to fetch data.</p>
  <p>Inside my Controller:</p>
  <pre><code>var Parameters = (from test in _db.tblAddTests
                 join par in _db.tblParameters on test.AddTestId equals 
                 par.TestId
                 where par.ParameterDatatype == 3
                 select new
                 {
                  ParameterId = par.ParameterId, 
                  ParameterName = par.ParameterName,
                  TestName = test.TestName
                  }
              ).ToList();
  ViewBag.Parameters = Parameters;
  </code></pre>
  <p>And I want to use this Parameters in my razor as:</p>
  <pre><code>@foreach (var item in ViewBag.Parameters)
  {
      &lt;option value=&quot;@item.ParameterId&quot;&gt;@item.ParameterName - @item.TestName&lt;/option&gt;
  }
  </code></pre>
  <p>It is currently giving me error that object as no definition for ParameterId.
  Although I have tried debugging and item is getting values as well but I am not sure how to display them,</p>
  <p>Here is screen shot of values I am getting
  Values in item variable:<br />
  <a href="https://i.stack.imgur.com/qG9rD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qG9rD.png" alt="Values in item variable" /></a></p>
  <p>Also Here is Screen shot of the error:</p>
  <p><a href="https://i.stack.imgur.com/byV7O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/byV7O.png" alt="Error" /></a></p>