From 91fcbd8b3e7d222b83e0c18b245a3337f610c35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 18 Sep 2022 22:08:58 +0300 Subject: [PATCH] Use TryAdd for adding entitycache --- .../EntityCacheServiceCollectionExtensions.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs index 6bded3c401..f426e9adcb 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; namespace Volo.Abp.Domain.Entities.Caching; @@ -8,11 +9,12 @@ public static class EntityCacheServiceCollectionExtensions this IServiceCollection services) where TEntity : Entity { - return services - .AddTransient< + services + .TryAddTransient< IEntityCache, EntityCacheWithoutCacheItem >(); + return services; } public static IServiceCollection AddEntityCache( @@ -20,11 +22,12 @@ public static class EntityCacheServiceCollectionExtensions where TEntity : Entity where TEntityCacheItem : class { - return services - .AddTransient< + services + .TryAddTransient< IEntityCache, EntityCacheWithObjectMapper >(); + return services; } public static IServiceCollection AddEntityCache( @@ -32,10 +35,11 @@ public static class EntityCacheServiceCollectionExtensions where TEntity : Entity where TEntityCacheItem : class { - return services - .AddTransient< + services + .TryAddTransient< IEntityCache, EntityCacheWithObjectMapperContext >(); + return services; } } \ No newline at end of file