title: C# MongoDb api - Geojson geometry store into a class
body: <p>That's my first time that i'm approaching mongodb api. 
  This is my code written up to now. I'm stuck because I can not save the polygon type coordinates inside my class and I can not run the GeoWithin function.</p>
  
  <pre><code>        //Connection
          MongoClient client = new MongoClient(path);
          var db = client.GetDatabase("ProgettoADM");
  
  
  
          //Getting the collections
          var restaurants = db.GetCollection&lt;Restaurants&gt;("restaurants");
          var neighborhood = db.GetCollection&lt;Neighborhood&gt;("neighborhood");
  
  
          // Creating variables for the query
          var longitude = -73.93414657;
          var latitude = 40.82302903;
          var point = new GeoJson2DGeographicCoordinates(longitude, latitude);
          var pnt = new GeoJsonPoint&lt;GeoJson2DGeographicCoordinates&gt;(point);
          var distance = 1609.34 * 5;
  
  
          //Index creation
          var restaurantsIndex = Builders&lt;Restaurants&gt;.IndexKeys.Geo2DSphere("location.coordinates");
          var neighborhoodIndex = Builders&lt;Neighborhood&gt;.IndexKeys.Geo2DSphere("geometry");
          restaurants.Indexes.CreateOne(restaurantsIndex);
          neighborhood.Indexes.CreateOne(neighborhoodIndex);
  
          //Filter creation for the NearSphere function            
          var nearSphereQuery = Builders&lt;Restaurants&gt;.Filter.NearSphere(p =&gt; p.location.coordinates, pnt, distance);
  
          //NearSphere Query execution
          List&lt;Restaurants&gt; nearSphereQueryResult = restaurants.Find(nearSphereQuery).ToListAsync().Result;
  
          //GeoIntersect Query execution
          var geoIntersectQuery = Builders&lt;Neighborhood&gt;.Filter.GeoIntersects("geometry", pnt);
          var c = neighborhood.Find(geoIntersectQuery).First();
  
          //Filter creation for the GeoWithin function
          var GeoWithinQuery = Builders&lt;Restaurants&gt;.Filter.GeoWithin(p =&gt; p.location.coordinates,/*data from variable c*/);
  </code></pre>
  
  <p>These are my classes to save data, the restaurants class works correctly, that neighborhood does not work.</p>
  
  <pre><code>       [BsonIgnoreExtraElements]
         public class Restaurants 
         {
            public ObjectId Id { get; set; }        
            public string name { get; set; }
            public Location location { get; set; }
         }
         [BsonIgnoreExtraElements]
         public class Location
         {               
            public double[] coordinates { get; set; }
            public string type { get; set; }
         }
  
         [BsonIgnoreExtraElements]
         public class Neighborhood
         {
           public ObjectId Id { get; set; }
           public string name { get; set; }
           public Geometry geometry { get; set; }
         }
  
         [BsonIgnoreExtraElements]
         public class Geometry
         {
           public BsonArray[] coordinates { get; set; }
         }
  </code></pre>
  
  <p>Thanks for your help!</p>