小编mao*_*vid的帖子

从子文档数组获取部分模型数组(MongoDB C#驱动程序)

我正在尝试接收仅使用MongoDB C#驱动程序填充的子字段的新数组。例如,我有以下文档:

{
    "_id" : "fca739d0-cddd-4762-b680-597d2996404b",
    "Status" : 1,
    "AccountId" : "1112",
    "Timestamp" : ISODate("2016-04-27T13:46:01.888Z"),
    "CartItems" : [ 
        {
            "ProductId" : "222",
            "Price" : 100,
            "ShippingPrice" : 20,
            "Quantity" : 3
        }, 
        {
            "ProductId" : "504",
            "Price" : 200,
            "ShippingPrice" : 20,
            "Quantity" : 2
        }, 
        {
            "ProductId" : "504",
            "Price" : 200,
            "ShippingPrice" : 20,
            "Quantity" : 1
        }, 
        {
            "ProductId" : "504",
            "Price" : 200,
            "ShippingPrice" : 20,
            "Quantity" : 1
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试CartItems仅接收具有的新数组的文档,ProductId …

c# mongodb mongodb-.net-driver

5
推荐指数
1
解决办法
201
查看次数

标签 统计

c# ×1

mongodb ×1

mongodb-.net-driver ×1