求救,C# mongoDB聚合数据后,如何转换为自定义的 对象List

求救,C# mongoDB聚合数据后,如何转换为指定的 对象List
例如:
从AnswerRecord 表中聚合出 count和 paperId等信息的List<TDocument>
转换为一个 指定的 List<Count>.

如下,我通过 ToList获得了一个List
想把这个List转为指定的 对象List
麻烦大佬们了

`

       var pipeCount = mRoot.answerRecord.GetAggregate().Match(x => x.userId == userId && x.subjectId == subjectId && x.visiable == 1)
            .Sort(BsonDocument.Parse("{ $sort: { 'mtime' : -1 } }"))
            .Group(BsonDocument.Parse("{ $group: { '_id' : {'cate':'$cate','paperId':'$paperId','sectionId':'$sectionId'} } }"))
            .Count().ToList();

`

   public IAggregateFluent<T> GetAggregate() => Collection.Aggregate();

`

    public IMongoCollection<T> Collection { get; }

`

阅读 1.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进