开发者

MongoDB Norm query nested objects

开发者 https://www.devze.com 2022-12-31 17:13 出处:网络
Does anyone ha开发者_如何学JAVAve 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

Does anyone ha开发者_如何学JAVAve 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.


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();
}


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

0

精彩评论

暂无评论...
验证码 换一张
取 消