0
// Traditional approach,
// fluent interface
BsonArray a2 = new BsonArray().Add(1).Add(2);

// Values argument
int[] values = new int[] { 1, 2 };
BsonArray a3 = new BsonArray(values); //It doesn't work in VB.NET

// Collection initializer syntax
BsonArray a4 = new BsonArray { 1, 2 }; //This doesn't work in VB.NET

特别是,我想在MongoDB VB.NET 驱动程序中找到“内部”框。

如何将以下语句合并为一行?

Dim b As New BsonDocument
Dim box As New BsonDocument
Dim d = New BsonArray({{1, 2}, {3, 5}})
box.Add("$box", d)
'box.Add("$box", d)
b.Add("$within", box)
query.Add("$within", box)
4

1 回答 1

2

为什么你说第二个和第三个不起作用?看来 BsonArray 构造函数有一个需要 a 的重载IEnumerable(Of Integer),所以这两个都应该工作(除了你的语法是错误的,也就是说。正确的语法是:

' values argument
Dim values() As Integer = {1, 2}
Dim a3 As BsonArray = New BsonArray(values)

' collection initializer syntax
Dim a4 As BsonArray = New BsonArray(New Integer(){1, 2})
于 2012-08-24T12:05:10.610 回答