title: How to find the min value of a specific field in MongoDB using C# driver 2.10.4
body: <p>Hi i am new in mongoDB and in C#. I want to find the min value of a specific filed from my collection.</p>
  
  <p>I have created the following class </p>
  
  <pre><code>     public class GlobalUrbanPoint
          {
              [BsonId]
              public ObjectId  Id{ get; set; }
              public double LATITUDE { get; set; }
              public double LONGITUDE { get; set; }
              ...
          }
  </code></pre>
  
  <p>For the operation I have following function for the connection and other.</p>
  
  <pre><code>     public class MongoCRUD
          {
              private IMongoDatabase db;
  
              public MongoCRUD(string database)
              {
                  var client = new MongoClient();
                  db = client.GetDatabase(database);
              }
              ...
              public void NormalizeCoordinates&lt;T&gt;(string table)
              {
                  var collection = db.GetCollection&lt;T&gt;(table);
                  // something is wrong the selection  
                  var result = collection.AsQueryable&lt;T&gt;().Select(LATITUDE =&gt; LATITUDE).Min&lt;T&gt;();
                  Console.WriteLine(result);
              }
          }
  </code></pre>
  
  <p>This is the <code>Main</code> function:</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using MongoDB.Bson;
      using MongoDB.Bson.Serialization.Attributes;
      using MongoDB.Driver;
      using MongoDB.Driver.Linq;
  
      static void Main(string[] args)
          {
              MongoCRUD db = new MongoCRUD("testClass");
  
              var newTable = "points";
  
              /* find The min value*/
              db.NormalizeCoordinates&lt;GlobalUrbanPoint&gt;(newTable);
           }
  </code></pre>
  
  <p>If I run this I get an exception : <code>System.NotSupportedException: '$project or $group does not support {document}.'</code></p>
  
  <p>I have try and a different approach that i found <a href="https://stackoverflow.com/questions/6360465/how-to-find-min-value-in-mongodb">here</a> with the use of FindAs().</p>
  
  <pre><code>    var cursor =  collection.FindAs&lt;T&gt;(Query.And()).SetSortOrder(SortBy.Ascending(fieldName)).SetLimit(1).SetFields(fieldName);
  </code></pre>
  
  <p>Again, I have the same luck.</p>
  
  <p>Can someone explain me how to get the min value properly from my collection.
  Thank you, for your time.</p>