You have a class like this (I just use GuidId.ToString () instead of guid):
public class Test
{
public Test()
{
TypeIds = new List<int>();
}
[BsonId]
public string Id { get; set; }
public string Country { get; set; }
public List<int> TypeIds { get; set; }
}
I inserted the rows in db according to the above docs
var collection = db.Database.GetCollection("items");
var id1 = Guid.NewGuid().ToString();
var id2 = Guid.NewGuid().ToString();
var test = new Test() { Id = id1, Country = "Germany" };
test.TypeIds.Add(47);
var test2 = new Test() { Id = id2, Country = "France" };
test2.TypeIds.Add(54);
test2.TypeIds.Add(47);
collection.Insert(test);
collection.Insert(test2);
Inquiries
var array = new List<int>() { 47, 54 };
var condition1 = collection.FindAs<Test>(Query.In("TypeIds", BsonArray.Create(array))).ToList();
var condition3 = collection.FindAs<Test>(Query.And(Query.EQ("TypeIds", 47), Query.EQ("Country", "Germany"))).ToList();
:
:
var array2 = new List<int>() { 47, 54 };
var query = Query.All("TypeIds",BsonArray.Create(array2));
var condition2 = collection.FindAs<Test>(query).ToList();