显示mongodb的平均值

时间:2019-01-24 20:47:12

标签: c# .net

    Display average value calculated from mongodb into c# application textbox

我正在使用mongodb作为数据库。我正在尝试在C#应用程序中使用这些值。例如  我的mongodb是嵌套文档,其值表示为“ cable_temp”。想要获取cable_temp的那些嵌套文档字段,想要获取平均值并将其显示在文本框中

Following is the mongodb databses values 
    {
            "_id" : ObjectId("5c49f398fc0078178c76705b"),  // object id
            "Time_Created" : ISODate("2019-01-24T17:19:20.205Z"),
            "Test_ID" : "1",
            "data" : [
                    {
                            "Device_id" : "1",
                            "Total_wires" : "5",
                            "Cables" : [
                                    {
                                            "TAG" : "4001",
                                            "cable_temp" : 24.3

                                    },
                                    {
                                            "TAG" : "4002",
                                            "cable_temp" : 21.3

                                    },
                                    {
                                            "TAG" : "4003",
                                            "cable_temp" : 21.3

                                    },
                                    {
                                            "TAG" : "4004",                                       
                                            "cable_temp" : 21.3

                                    },                                                            
                                    {
                                            "TAG" : "4005",                                        
                                            "cable_temp" : 100.3

                                    }
                            ]
                    }
            ]
    }

cable_temp是我要在C#应用程序中收集并取平均值的值 无法将cable_temp的平均值输入C#文本框

0 个答案:

没有答案