Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有人有如何使用 NORM (C#) 在 MongoDB 中查询嵌套/内部对象的示例?例如,如果集合中的典型文档看起来像 Order/OrderItems,我如何通过 OrderItem.Quantity > 10 查找特定的 OrderItem。
您需要创建额外的字段“大小”,在添加新项目时增加该字段并对其进行查询。
凭记忆输入,如有错误,请见谅:
using ( var session = new MongoSession<Order>( DbName ) ) { var orders = session.Queryable .Where( o => o.OrderItems.Any( oi => oi.Quantity > 10 ) ) .ToList(); }