-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Index Management
-
None
-
Dotnet Drivers
Summary
We are trying to update to the latest Mongo C# Driver to use the new EntityFramework lib, but haven’t been able to get past a breaking change that was bug (or perhaps a bug that was introduce) in v2.23.0. In v2.22.0 and prior, we have been able to pass Dictionary.Keys in an Expression via IndexKeysDefinitionBuilder. For example:
public class Thing { [BsonRepresentation(BsonType.ObjectId)] [BsonIgnoreIfDefault] public string Id { get; set; } public string Name { get; set; } public Dictionary<string,string> Attributes { get; set; } } // Given the following protected static IndexKeysDefinitionBuilder<TEntity> Index => Builders<TEntity>.IndexKeys; // Some data layer code that builds indexes var collection = database.GetCollection<Thing>("things"); await collection.Indexes.CreateOneAsync( new CreateIndexModel<Thing>( Index.Combine( Index.Ascending(o => o.Name), Index.Ascending(o => o.Attributes.Keys))));
Is there a different way to build this Expression now or was this a bug that got introduced? Any guidance is appreciated.