MongoDB .NET驱动程序:使用第一个累加器进行分组

时间:2016-02-03 17:38:56

标签: mongodb mongodb-query mongodb-.net-driver

是否可以使用.NET Driver 2.2在聚合管道中对$ first累加器进行分组?

我正在尝试使用驱动程序编写以下查询:

db.collection.aggregate( 
    [ 
        {
            $sort : { "createdDate" : -1 }
        },
        { 
            $group : { 
                _id : "$key",
                latestEntity : { $first : "$$ROOT" }
            }            
        }
    ]

.NET:

var result = collection
                .Aggregate()
                .SortByDescending(x => x.CreatedDate)
                .Group(k => k.Key, x => x.First())
                .ToList();

使用&#34投放System.NotSupportException;不支持指定方法"。

0 个答案:

没有答案