title: sequence contains no elements Error Max()
body: <p>I am Getting:</p>
  
  <blockquote>
    <p>sequence contains no elements</p>
  </blockquote>
  
  <pre><code>private int? GetPrecedingSibling(int? contentid,int? templateid)
  {
      var value = _sequenceTemplateItemService.Query(e =&gt; e.templateId == templateid &amp;&amp; e.contentItemId == contentid).Select(t =&gt; t.id).Max();
      if (value != 0)
          return value; 
      return null;
  }
  </code></pre>