如何在MongoDB驱动程序的IList中创建Include特定字段



我想了解如何在MongoDB驱动程序(任何解决方案(中创建List中的Include特定字段

当我尝试包含某些属性时例如:

var projection = Builders <SomeClass> .Projection
.Include (x => x.Id)

它的工作没有任何问题。

但当我试图从一张中包含一个特定的字段时

var projection = Builders <SomeClass> .Projection
.Include (x => x.ListOfSomeClasses.Select (x => x.SomeProperty))

我得到这个异常

Error occurred during request execution
System.InvalidOperationException: Unable to determine the serialization information for x => x.ListOfSomeClasses.Select (x => x.SomeProperty).

在此之前,我曾与postgres合作,那里没有这样的问题。

也许Mongo中存在一些问题。任何答案都对我很有帮助。谢谢

c#驱动程序允许使用原始MQL进行LINQ查询,而这些查询在类型化方式中不受支持:

var projection = Builders<SomeClass>.Projection
.Include("ListOfSomeClasses.SomeProperty");

最新更新