【发布时间】:2019-01-17 11:51:19
【问题描述】:
要使用 de MongoDB C# Driver 执行推送,我需要实例化 FieldDefinition<MyMongoDocumentType, MyNestedArrayType[]>。
我知道我可以使用字符串实例化这个FieldDefinition...
FieldDefinition<MyMongoDocumentType, NestedArrType[]> field = "MyArray.$.MyNestedArray";
我也尝试过使用 Linq 表达式,如下所示:
FieldDefinition<MyMongoDocumentType, NestedArrType[]> field =
new ExpressionFieldDefinition<MyMongoDocumentType, NestedArrType[]>(
doc => doc.MyArray.First().MyNestedArray
);
但我得到了这个错误:
System.InvalidOperationException:无法确定 doc => 的序列化信息 doc.MyArray.First().MyNestedArray.
有没有办法使用行之有效的 Linq 表达式创建嵌套数组的 FieldDefinition?
【问题讨论】:
标签: c# mongodb linq mongodb-.net-driver