title: Query MongoDB Using 'ObjectId'
body: <p>I have inserted <code>document</code>s into MongoDB without an <code>id</code>. And I want to retrieve them by searching through their <a href="https://docs.mongodb.org/manual/reference/method/ObjectId/" rel="noreferrer">MongoDB <code>ObjectId</code></a>, that has been assigned <em>in default</em>.</p>
  
  <p>Here is my attempt-</p>
  
  <pre><code>var query_id = Query.EQ("_id", "50ed4e7d5baffd13a44d0153");
  var entity = dbCollection.FindOne(query_id);
  return entity.ToString();
  </code></pre>
  
  <p>And I get following error-</p>
  
  <blockquote>
    <p>A first chance exception of type 'System.NullReferenceException' occurred</p>
  </blockquote>
  
  <p>What is the problem?</p>