title: No matching creator found
body: <p>Recently I have made migration from mongosharp 1.8 to 2.0 .The only problem I have faced is aggregation with date fields.Let me show you how I construct query :</p>
  
  <pre><code>var aggregateResult = Items.Aggregate()
      .Group(
          g =&gt; new {
              // some fields
              Day = g.DateTime.DayOfYear
          },
          z =&gt; new {
              MyKey = z.Key
              // agrregation functions
          })
      .Project(
          d =&gt; new {
              // projection for other fields
              d.MyKey.Day
          });
  </code></pre>
  
  <p>I used <a href="https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver.Tests/Samples/AggregationSample.cs#L105" rel="noreferrer">this</a> example from <a href="http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/crud/reading/#aggregation" rel="noreferrer">documentation</a>.</p>
  
  <p>I got the following exception: <code>No matching creator found.</code> I have checked generated query and manually executed it - result was perfect. After reproducing test code and compare to my I find problem is in dates. So, can anyone point me to correct syntax/query rules  for dates? The generated query below proves that query is correct.</p>
  
  <pre><code>aggregate(
  [
      {
          "$group" : {
              "_id" : {
                  "Day" : {
                      "$dayOfYear" : "$DateTime"
                  }
              },
          }
      },
      {
          "$project" : {
              "Day" : "$_id.Day",
              "_id" : 0
          }
      }
  ])
  </code></pre>
  
  <p><b>Workaround</b></p>
  
  <p>So, to make things work I do next workaround:</p>
  
  <ul>
  <li>create aggregate helper class which encapsulates access to database using Legacy assembly.</li>
  <li>implement methods which used queries constructed on bson documents </li>
  <li>inject it to my async 2.0 service and replace async calls with sync</li>
  </ul>
  
  <p>Below is code to get collection and execute queries</p>
  
  <pre><code>_collection = new MongoDatabase(new MongoServer( MongoServerSettings.FromUrl(connectionString)), databaseName, new MongoDatabaseSettings()).GetCollection&lt;MyClass&gt;("collection_name"); 
  var pipeline = new[] { match, groupBy, project, .... };
  _collection.Aggregate(new AggregateArgs { Pipeline = pipeline }).ToList()
  </code></pre>