[CSHARP-1700] Add dateOperator extensions Created: 07/Jul/16  Updated: 07/Jul/16  Resolved: 07/Jul/16

Status: Closed
Project: C# Driver
Component/s: Feature Request
Affects Version/s: 2.2.4
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Greg Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

when using grop/project phase I'd to have ability to use typed extension instead of passing bson document

var project =
BsonDocument.Parse(
"{Key:1, Timestamp:1, year:{$year:'$Timestamp'}, dayOfYear:{$dayOfYear:'$Timestamp'}}");
var group = BsonDocument.Parse("{_id:

{year:'$year', dayOfYear:'$dayOfYear'}

, count:{$sum:1}}");
var result = collection.Aggregate().Project(project).Group(group).ToList();

in this case i will expect that project will look like this:

.Project(i => new

{ i.Key, dayOfYear = i.Timestamp.GetDayOfYear, year = i.Timestamp.GetYear }

):



 Comments   
Comment by Craig Wilson [ 07/Jul/16 ]

We already support these. You can see the list of supported date operations here: http://mongodb.github.io/mongo-csharp-driver/2.2/reference/driver/expressions/#date-expressions.

I'm going to close this, but if you find that what I've pointed to isn't what you are asking, please re-open the ticket.

Craig

Generated at Wed Feb 07 21:40:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.