From 53a8babfa78e839be67611e20696059358ef3d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 27 Aug 2025 12:24:10 +0300 Subject: [PATCH] Rename SetCustomEntityName to SetEntityName in repositories Refactored repository interfaces and implementations to replace SetCustomEntityName and CustomEntityName with SetEntityName and EntityName for consistency and clarity. Updated related extension methods and tests to use the new naming. --- .../Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs | 6 +++--- .../Volo/Abp/Domain/Repositories/IRepository.cs | 2 +- .../Volo/Abp/Domain/Repositories/RepositoryExtensions.cs | 9 +++++++++ .../Repositories/EntityFrameworkCore/EfCoreRepository.cs | 4 ++-- .../Domain/Repositories/RepositoryRegistration_Tests.cs | 2 +- .../Repositories/SharedEntity_Repository_Tests.cs | 8 ++++---- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs index 1d058d19b9..f85a156184 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs @@ -44,11 +44,11 @@ public abstract class BasicRepositoryBase : public bool? IsChangeTrackingEnabled { get; protected set; } - protected string? CustomEntityName { get; private set; } + protected string? EntityName { get; private set; } - public void SetCustomEntityName(string? name) + public void SetEntityName(string? name) { - CustomEntityName = name; + EntityName = name; } protected BasicRepositoryBase() diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs index c5942088f0..d5a66b1fe7 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs @@ -14,7 +14,7 @@ public interface IRepository { bool? IsChangeTrackingEnabled { get; } - void SetCustomEntityName(string? name); + void SetEntityName(string? name); } public interface IRepository : IReadOnlyRepository, IBasicRepository diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs index 3c43798c38..9fc9c16d31 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs @@ -250,4 +250,13 @@ public static class RepositoryExtensions hardDeleteEntities.Add(entity); await repository.DeleteAsync(entity, autoSave, cancellationToken); } + + public static TRepository WithEntityName( + this TRepository repository, + string name + ) where TRepository : class, IRepository + { + repository.SetEntityName(name); + return repository; + } } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs index 760660dc82..fd61e72781 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs @@ -122,8 +122,8 @@ public class EfCoreRepository : RepositoryBase, IE private DbSet GetDbSetInternal(TDbContext dbContext) { - return CustomEntityName != null - ? dbContext.Set(CustomEntityName) + return EntityName != null + ? dbContext.Set(EntityName) : dbContext.Set(); } diff --git a/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs b/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs index 63aa0e3411..193bbaed14 100644 --- a/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs +++ b/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs @@ -409,7 +409,7 @@ public class RepositoryRegistration_Tests { public bool? IsChangeTrackingEnabled { get; set; } - public void SetCustomEntityName(string name) + public void SetEntityName(string name) { } diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/SharedEntity_Repository_Tests.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/SharedEntity_Repository_Tests.cs index abdc7a4e6d..869069debe 100644 --- a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/SharedEntity_Repository_Tests.cs +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Repositories/SharedEntity_Repository_Tests.cs @@ -29,7 +29,7 @@ public class SharedEntity_Repository_Tests : EntityFrameworkCoreTestBase { await WithUnitOfWorkAsync(async () => { - TestSharedTypeEntityRepository.SetCustomEntityName("TestSharedEntity1"); + TestSharedTypeEntityRepository.SetEntityName("TestSharedEntity1"); var tenantId = Guid.NewGuid(); await TestSharedTypeEntityRepository.InsertManyAsync(new List() @@ -121,7 +121,7 @@ public class SharedEntity_Repository_Tests : EntityFrameworkCoreTestBase } } - TestSharedTypeEntityRepository.SetCustomEntityName("TestSharedEntity2"); + TestSharedTypeEntityRepository.SetEntityName("TestSharedEntity2"); await TestSharedTypeEntityRepository.InsertManyAsync(new List() { new TestSharedEntity(Guid.NewGuid()) @@ -146,7 +146,7 @@ public class SharedEntity_Repository_Tests : EntityFrameworkCoreTestBase { await WithUnitOfWorkAsync(async () => { - TestSharedTypeEntityRepository.SetCustomEntityName("TestSharedEntity1"); + TestSharedTypeEntityRepository.SetEntityName("TestSharedEntity1"); var entity = new TestSharedEntity(Guid.NewGuid()) { @@ -169,7 +169,7 @@ public class SharedEntity_Repository_Tests : EntityFrameworkCoreTestBase entity.Birthday.ShouldNotBeNull(); entity["DynamicProperty"].ShouldBe("Test Value1"); - TestSharedTypeEntityRepository.SetCustomEntityName("TestSharedEntity2"); + TestSharedTypeEntityRepository.SetEntityName("TestSharedEntity2"); entity = await TestSharedTypeEntityRepository.FindAsync(x => x.Id == entity.Id!); entity.ShouldBeNull(); });