title: How to handle a DataServiceQuery that returns 0 matches
body: <p>I have created a simple WCF Data Service in Visual Studio 2013 in c#.</p>
  
  <p>I then created a web application using asp.net and c#.</p>
  
  <p>I have 2 textboxes and a button.</p>
  
  <p>I put a code in the first text box.  I press the button.  the following code runs.  If the code i entered matches a record in the list exposed by the webservice, no problems.  </p>
  
  <p>However, if i enter a code that doesn't exist, I have no clues how to test for that.  Right now the only thing that works is a Try Catch, but I can't believe this is the proper of doing this.</p>
  
  <pre><code> var proxy = new NorthwindEntities(new Uri("http://localhost:27214/NorthwindCustomers.svc"));
  
              var customers = proxy.Customers;
  
              if (string.IsNullOrEmpty(Code.Text))
              { return; }
  
              var customer = (from c in customers where c.CustomerID == Code.Text select c).Single();
  
              if (customer == null) //If there are no customers... it gives me an error.
              {
                  Nom.Text = null;
              }
              else
              {
                  Nom.Text = customer.CompanyName;
              }
  
              Code.Text = string.Empty;
  </code></pre>