MyNameIsSkrillex
MyNameIsSkrillex

Reputation: 29

MongoDb c# driver need to compare datetime

The following code

var query = Query.And(
                  Query.EQ("p2l.listId", mailListId),
                  Query.LTE("p2l.subscriptionDate", dateTime.ToIsoDateTime())
                  );
return query;

Will give the following result

{  
   "p2l.listId":39974,
   "p2l.subscriptionDate":{  
      "$gte":"ISODate('2015-07-01 00:00:00')"
   }
}

ToIsoDateTime -is my custom extention method

How to prevent wrapping the ISODate with " ? Query will work fine without a double quotes. The way with lambda-query is not convenient for me, how can i implement it ?

Upvotes: 0

Views: 1023

Answers (1)

MyNameIsSkrillex
MyNameIsSkrillex

Reputation: 29

There is only need to use dateTime without extension method and it will work fine.

Upvotes: 1

Related Questions