【发布时间】:2021-04-05 11:40:17
【问题描述】:
我正在尝试使用 BsonSerializer 将 BsonDocuments 列表反序列化为类 Type,但出现错误“无法从 'System.Collections.Generic.List
如何反序列化 BsonDocument 列表以列出类类型?
var projection = Builders<Property>.Projection
.Include(x => x.Type);
var values= await MongoCollection
.Find(Builders<Property>.Filter.Empty)
.Project(projection)
.ToListAsync()
.ConfigureAwait(false);
var test = BsonSerializer.Deserialize<IEnumerable<Property>>(values);
【问题讨论】:
-
这个链接可能对stackoverflow.com/questions/46768516/…有帮助,我认为你可以在代码中使用带有类型的集合。
标签: c# mongodb mongodb-.net-driver