Given the following classes:
public class User { public Object Id { get; set; } public IEnumerable<Login> Logins { get; set; } // etc... } public class Login { public string LoginProvider { get; set; } public string ProviderKey { get; set; } // etc... }
There should be a type-safe way to create multikey indexes on members of the embedded Login documents. One possible way to express that could be:
var indexKeysDefinition = Builders<User>.IndexKeys
.Ascending(user => user.Logins.Select(login => login.LoginProvider))
.Ascending(user => user.Logins.Select(login => login.ProviderKey));
Workaround
Use strings instead.
var indexKeysDefinition = Builders<User>.IndexKeys .Ascending("Logins.LoginProvider") .Ascending("Logins.ProviderKey");
- depends on
-
CSHARP-1955 Add a type safe way to use the IndexKeys builder to create an index on a nested field of an array of documents
- Closed
- is duplicated by
-
CSHARP-1340 Provide a type-safe way to create multikey indexes
- Closed