With the following structure:
class A
{
...
List<B> L;
}
class B
{
...
string S;
}
and a collection of objects A, is it possible to create an index on the S fields?
Update: The solution proposed in the comments does NOT work:
public class A
{
public List<B> L;
public A()
{
L = new List<B>();
}
}
public class B
{
public string S;
}
and index creation:
MongoCollection.Indexes.CreateOne(new BsonDocument {{ "B.S", 1}});
yields:
only the _id field gets indexed, but B.S is not.

await collection.Indexes.CreateOneAsync(new BsonDocument {{"name", 1}, {"bars.key", 1}});