title: How to check if ObjectResult collection was empty?
body: <p>I have this piece of code which check the last customer_id from the db.</p>
  
  <pre><code>ObjectResult&lt;int?&gt; last_customer_id_collection = MainForm.eggsContext.ExecuteStoreQuery&lt;int?&gt;("select MAX(customer_id) from customers");
  </code></pre>
  
  <p>Then I get the next id required like this</p>
  
  <pre><code>new_customer_id = last_customer_id_collection.FirstOrDefault&lt;int?&gt;().Value + 1;
  </code></pre>
  
  <p>It's working, HOWEVER when dealing with a new empty db the statment <code>last_customer_id_collection.FirstOrDefault&lt;int?&gt;()</code> throws an InvalidOperationException. </p>
  
  <p>How can I check if last_customer_id_collection was empty without try catch?</p>
  
  <p>(p.s. I was trying to check if <code>last_customer_id_collection.Any&lt;int?&gt;()</code> or <code>last_customer_id_collection.Count&lt;int?&gt;()</code> or DefaultIfEmpty etc. but everything I try causes this exception)</p>