title: Comparing dates in Mongodb with C# LINQ driver
body: <p>I have a MongoDB collection with a string field representing a date. In my C# app I map the results to a class with an aggregate field that convert that string to a DateTime object</p>
  
  <pre><code>[BsonIgnoreExtraElements]
  public class Tweet
  {
      public ObjectId Id { get; set; }
  
      [BsonElement("text")]
      public string Texto { get; set; }
  
      [BsonElement("created_at")]
      public string Fecha { get; set; }
  
      public DateTime FechaConvertida
      {
          get
          {
              var formato = "ddd MMM dd HH:mm:ss zzzz yyyy"; //'Sun Oct 23 19:42:04 +0000 2016'
              var enUS = new CultureInfo("en-US");
              var fechaConvertida = DateTime.ParseExact(this.Fecha, formato, enUS, DateTimeStyles.None);
              return fechaConvertida;
          }
      }
  }
  </code></pre>
  
  <p>Then on my api I make a query filtering elements between two dates (using 'CSharp Driver LINQ')</p>
  
  <pre><code>public IEnumerable&lt;Tweet&gt; GetTweetsDePeriodo(string nombreColeccion, int dias)
      {
          var hoy = DateTime.Today;
          var fechaInicial = hoy.AddDays(-dias);
  
          var coleccion = _db.GetCollection&lt;Tweet&gt;(nombreColeccion).AsQueryable&lt;Tweet&gt;();
          var tweetsFiltrados = (from c in coleccion
                                 where c.FechaConvertida &gt;= fechaInicial
                                 select c
                                 ).ToList();
          return coleccion;
      }
  </code></pre>
  
  <p>And then I get the following error: 
  <strong>*An unhandled exception occurred while processing the request.
  InvalidOperationException: {document}.FechaConvertida is not supported</strong></p>
  
  <p>Any idea?
  Thanks in advance,</p>