title: 'Sequence contains no elements', happening?
body: <p>It's a WINDOWSFORM</p>
  
  <p>I have combobox, I use this code for auto textboxvalue but I receive this error</p>
  
  <blockquote>
    <p>Sequence contains no elements</p>
  </blockquote>
  
  <pre><code>private void cmbOfficeNumber_SelectedIndexChanged(object sender, EventArgs e)
  {
      using (UnitOfWork db = new UnitOfWork())
  
      if (cmbOfficeNumber.SelectedValue.ToString() != null)
      {
          txtOfficeName.Text = db.OfficeRepository.GetOfficeNamebyNumber(cmbOfficeNumber.Text);
  
      }
  }
  </code></pre>
  
  <p>And this is my repository code</p>
  
  <pre><code>public string GetOfficeNamebyNumber(string officeNumber)
  {
      return db.Office.First(g =&gt; g.OfficeNumber == officeNumber).OfficeName;
  }
  </code></pre>
  
  <p>EDIT: When using</p>
  
  <pre><code>return db.Office.FirstOrDefault(g =&gt; g.OfficeNumber == officeNumber).OfficeName;
  </code></pre>
  
  <p>I receive a different error </p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object</p>
  </blockquote>