How to create index based on nested array element in C# Mongodb strongly typed driver

Refresh

6 days ago

Views

6 time

1

This question is quite on the same principles as this one but I'd like to create an index using strongly typed approach on an object property when this object is nested in an array of the collection.

I can use:

new CreateIndexModel<T>( Builders<T>.IndexKeys.Ascending( a ) )

where a is an Expression which accesses to a direct property.

But I've found nothing similar to:

Builders<Library>.Filter.ElemMatch(x => x.Author.Books, b => b.IsVerified == false));

so that I can define as index some field of an object nested in an array which is a member of the collection.

Is that possible to do it and how?

0 answers