title: How to debug an empty LINQ result query?
body: <p>I've added a query to my repository, that queries for a list of orders that match the email search key. But when I step through the method, my result is null although the email string matches the email stored in my orders database document, <code>"email": "brianvarley@gmail.com"</code></p>
  
  <p>I'm using the <a href="https://docs.mongodb.org/ecosystem/drivers/csharp/" rel="nofollow noreferrer">MongoDB.Net driver</a> to communicate with the MongoLabs repository. My other queries to query all documents works so doesn't seem to be a connection issue.</p>
  
  <p><a href="https://i.stack.imgur.com/Lg6bR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lg6bR.png" alt="debug result"></a></p>
  
  <p>I tried hovering over <code>c.Email</code>, to check the database result, but no values pop up.</p>
  
  <p>Does anyone know how I can debug the null result further?</p>
  
  <p>This is the method that queries orders by email:</p>
  
  <pre><code>    public async Task&lt;List&lt;OrderModel&gt;&gt; GetAllByEmailAsync(string email)
      {
          if (orderList == null)
              await LoadDbAsync();
          return orderList.Where(c =&gt; c.Email == email).ToList();
      }
  </code></pre>
  
  <p>I added a dump to check orderList contents, but that shows a count = 0:</p>
  
  <pre><code>string dump = string.Join(",", orderList.ToString());
  </code></pre>
  
  <p>This is the <code>LoadDBAsync()</code>, when I step through the code, this method is skipped as OrderList isn't null:</p>
  
  <pre><code>    public async Task LoadDbAsync()
      {
          var orderCollection = StartConnection();
  
          try
          {
              orderList = await orderCollection.Find(new BsonDocument()).ToListAsync();
  
          }
          catch (MongoException ex)
          {
              //Log exception here:
              MessageBox.Show("A connection error occurred: " + ex.Message, "Connection Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
          }
      }
  </code></pre>
  
  <p>And the <code>StartConnection()</code> called from LoadDbAsync:</p>
  
  <pre><code>    public IMongoCollection&lt;OrderModel&gt; StartConnection()
      {
  
          var client = new MongoClient(connectionString);
          var database = client.GetDatabase("orders");
          //Get a handle on the customers collection:
          var collection = database.GetCollection&lt;OrderModel&gt;("customer_orders");
          return collection;
      }
  </code></pre>