4

Does anyone have a sample of how to query for nested/inner objects in MongoDB using NORM (C#)? For example, if a typical document in a collection looks like Order/OrderItems, how can I look up a specific OrderItem by OrderItem.Quantity > 10.

Kevin Pullin
  • 13,122
  • 3
  • 24
  • 33
Howard
  • 165
  • 1
  • 5

2 Answers2

0

Typing this from memory, so sorry if it's wildly wrong:

using ( var session = new MongoSession<Order>( DbName ) )
{
    var orders = session.Queryable
                .Where( o => o.OrderItems.Any( oi => oi.Quantity > 10 ) )
                .ToList();
}
Brett Nagy
  • 67
  • 1
  • 4
0

You need to create extra field 'size', that you increment when add new items, and query on it.

Andrew Orsich
  • 52,935
  • 16
  • 139
  • 134