-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.0.1
-
Component/s: API
-
None
As background, consider first the following classes:
public class Product { public ObjectId Id; public Review Review; } public class Review { public string Author; // etc... }
Given these classes, one can easily create an index on the Author of a Review in a type-safe manner:
var builder = Builders<Product>.IndexKeys; var keys = builder.Ascending(x => x.Review.Author);
However, suppose that instead of one Review, the Product class defined an enumerable of Reviews?
public class Product { public ObjectId Id; public Review[] Reviews; }
If you attempt to create an index on the Authors of the Reviews you get a compile time error:
var builder = Builders<Product>.IndexKeys; var keys = builder.Ascending(x => x.Reviews.Author); // compile time error!
We need some way to support creating multikey indexes in a type-safe way.
- duplicates
-
CSHARP-1309 IndexKeysDefinitionBuilder should support defining multikey indexes on members of an array of embedded documents
- Closed