且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#从MongoDB中的数组检索值

更新时间:2023-02-23 08:58:24

我通过进行以下更改找到了解决方案,现在它可以正常工作:

I figured out the solution, by making the following changes and it works now:

foreach (BsonDocument nestedDocument in Document["name"].AsBsonArray)
                        {
                            Total += Convert.ToDouble(nestedDocument["amount"]);
                        }