title: Can't set nullable int to LINQ query's return value?
body: <p>I want to retrieve an Id from a table based on certain criteria.  If the criteria isn't met, I just want to return the default value (in this case, I'm assuming null).  Here's my code:</p>
  
  <pre><code>int? circuitTypeId = cimsContext.CircuitTypes.FirstOrDefault(ct =&gt; ct.Name == circuitType).Id;
  </code></pre>
  
  <p>I am assuming that if there isn't a match between <code>ct.Name</code> and <code>circuitType</code> that the value returned is <code>null</code>.  However, when running my program, I get an error on this line saying "Null reference exception".  I know that the record isn't there, but shouldn't I be able to assign the <code>null</code> returned by the query to my <code>nullable int</code> variable?</p>