Either
HashSet<string> aaa { get; set; }
or
List<string> aaa { get; set; }
or
string[] aaa { get; set; }
also store as:
"aaa": {
"0": "bbb",
"1": "ccc"
},
can't store as
"aaa": ["bbb", "ccc"]
?
The following code with the latest 10gen drivers produces the document in the format you're looking for:
public class MyDocument
{
public int id { get; set; }
public string[] aaa { get; set; }
}
class Program
{
private static void Main(string[] args)
{
var client = new MongoClient("mongodb://localhost");
var server = client.GetServer();
var db = server.GetDatabase("temp");
var coll = db.GetCollection("myDocuments");
var mydoc = new MyDocument
{
id = 1,
aaa = new[] {"bbb", "ccc"}
};
coll.Save(mydoc);
}
}
Here is the resulting document:
/* 0 */
{
"_id" : 1,
"aaa" : [
"bbb",
"ccc"
]
}
IList and List also work. Do you have any custom BSON serialization annotations? Do you have custom class maps?