title: Mongodb C# integration with null fields for some record
body: <p>This is my json file.</p>
  
  <pre><code>{"_id":{"$oid":"569c6f31f633b10994233f16"},"Name":"jawad","Salary":"1000"}
  
  {"_id":{"$oid":"569c7044f633b126c825e880"},"Name":"noor","Salary":"1000"}
  
  {"_id":{"$oid":"569c97df47c0e25eb3af5928"},"Name":"jawad","Salary":5000.0}
  
  {"_id":{"$oid":"569ca7a9f633b11ba42ffecc"},"Name":"mustaf","Salary":"9000","Telephone":["0700221569","0093799346211"]}
  
  {"_id":{"$oid":"569cb94bf633b12e70eefa10"},"Name":"ramin","Salary":"14000"}
  
  {"_id":{"$oid":"569cb98b617a84b98faf34ca"},"_Id":null,"Name":"ts","Salary":"4444"}
  
  {"_id":{"$oid":"569cba2e617a84b98faf34cb"},"ID":null,"Name":"Dingo","Salary":"90004"}
  </code></pre>
  
  <p>C# code</p>
  
  <pre><code>protected void btnSearch_Click(object sender, EventArgs e)
  {
      String ConnectionString = "mongodb://localhost:27017";
      MongoClient MC = new MongoClient(ConnectionString);
      var DB = MC.GetDatabase("test");
      var Col = DB.GetCollection&lt;Result&gt;("Product2");
      var filter=Builders&lt;Result&gt;.Filter.Eq("Name",txtName.Text);
      var Result = Col.Find(filter).SortByDescending(x=&gt;x.Salary).ToList();
  
      var query = (from r in Col.AsQueryable&lt;Result&gt;().Where&lt;Result&gt;(x =&gt; x.Name == txtName.Text).SortBy&lt;Result&gt;("Salary")
                   select new
                    {
                        Id = r._Id,
                        Name = r.Name,
                        Salary = r.Salary,
                        Telephone=r.Telephone
                    }).ToList();
  
      // count of total records.
  
      int TotalElements = query.Count();
      lblTotal.Text = TotalElements.ToString();
  
      gvResult.DataSource = query;
      gvResult.DataBind();
  }
  
  
  
  public class Result
  {
      [BsonId]
      public ObjectId _Id { get; set; }
      [BsonElement]
      public String Name { get; set; }
      public double Salary { get; set; }
      [BsonElement]
      public List&lt;String&gt; Telephone { get; set; }
  
  }
  </code></pre>
  
  <p>Aspx file</p>
  
  <pre><code>&lt;div class="Body"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name&lt;/td&gt;&lt;td&gt;&lt;asp:TextBox runat="server" ID="txtName" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Salary&lt;/td&gt;&lt;td&gt;&lt;asp:TextBox runat="server" ID="txtSalary" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;asp:Label runat="server" ID="lblID"&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Button Text="Save" runat="server" ID="btnSave" OnClick="btnSave_Click" /&gt;
                      &lt;asp:Button Text="Search" runat="server" ID="btnSearch" OnClick="btnSearch_Click" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
  
  
      &lt;asp:GridView runat="server" ID="gvResult"&gt;
  
      &lt;/asp:GridView&gt;
  
      &lt;div class="CountDiv"&gt;
      &lt;span&gt;Total Elements:&lt;/span&gt;&lt;asp:Label runat="server" ID="lblTotal"&gt;&lt;/asp:Label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have 1 telephone field for one record but not for the rest how can I make the query to scape null telephone I get error:</p>
  
  <blockquote>
    <p>No matching creator found.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/7nFBb.jpg" rel="nofollow noreferrer">enter image description here</a></p>