将BsonDocument投影到聚合管道中的Type中

时间:2018-12-07 10:34:47

标签: c# mongodb mongodb-.net-driver

我有一个聚合管道,可以提取正确的BsonDocument格式,现在我想将其转换为实际的类型。

var msgs =
 _edges
   .Aggregate()
   .Match(e => e.Type == EdgeType && e.From == FromId)
   .Lookup("messages", "To", "_id", "msg")
   .Unwind(b => b["msg"])
   .ReplaceRoot(b => b["msg._xlc"])
   .Project<Message>("{??}")                
   .ToList();

我需要给Project阶段什么以使其原样通过BsonDocument并将其转换为Message类型?我尝试了"{}"""b=>b,但它只是。惯于。 udge ..

我还看到ReplaceRoot阶段输出的是BsonValue类型而不是BsonDocument。

帮助:)

0 个答案:

没有答案