diff --git a/src/KafkaFlow.Retry.MongoDb/Model/DboConfigurations.cs b/src/KafkaFlow.Retry.MongoDb/Model/DboConfigurations.cs index fa3a880f..1e9196f7 100644 --- a/src/KafkaFlow.Retry.MongoDb/Model/DboConfigurations.cs +++ b/src/KafkaFlow.Retry.MongoDb/Model/DboConfigurations.cs @@ -18,15 +18,15 @@ internal static void TryAddIndexes(DbContext dbContext) ), new CreateIndexModel( Builders.IndexKeys.Ascending(x => x.QueueGroupKey), - new CreateIndexOptions{ Unique = true } + new CreateIndexOptions { Unique = true } ), new CreateIndexModel( Builders.IndexKeys.Ascending(x => x.Status) ), - new CreateIndexModel( + new CreateIndexModel( Builders.IndexKeys.Descending(x => x.CreationDate) ), - new CreateIndexModel( + new CreateIndexModel( Builders.IndexKeys.Ascending(x => x.LastExecution) ) } @@ -53,23 +53,17 @@ internal static void TryAddIndexes(DbContext dbContext) internal static void TryRegisterClassMapppings() { - if (!BsonClassMap.IsClassMapRegistered(typeof(RetryQueueDbo))) + BsonClassMap.TryRegisterClassMap(cm => { - BsonClassMap.RegisterClassMap(cm => - { - cm.AutoMap(); - cm.MapIdProperty(q => q.Id).SetIdGenerator(new GuidGenerator()); - }); - } + cm.AutoMap(); + cm.MapIdProperty(q => q.Id).SetIdGenerator(new GuidGenerator()); + }); - if (!BsonClassMap.IsClassMapRegistered(typeof(RetryQueueItemDbo))) + BsonClassMap.TryRegisterClassMap(cm => { - BsonClassMap.RegisterClassMap(cm => - { - cm.AutoMap(); - cm.MapIdProperty(q => q.Id).SetIdGenerator(new GuidGenerator()); - }); - } + cm.AutoMap(); + cm.MapIdProperty(q => q.Id).SetIdGenerator(new GuidGenerator()); + }); } } } \ No newline at end of file