diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs index db0ec2b11c..1d4e6e6771 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -6,9 +6,7 @@ using System.Linq; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; -using Volo.Abp.Data; using Volo.Abp.Domain.Entities; -using Volo.Abp.Linq; using Volo.Abp.MultiTenancy; using Volo.Abp.Uow; diff --git a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs index 7c67e254ee..996143069d 100644 --- a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs +++ b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs @@ -28,23 +28,19 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb protected IMemoryDatabaseProvider DatabaseProvider { get; } - public ILocalEventBus LocalEventBus { get; set; } + public ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetService(NullLocalEventBus.Instance); - public IDistributedEventBus DistributedEventBus { get; set; } + public IDistributedEventBus DistributedEventBus => LazyServiceProvider.LazyGetService(NullDistributedEventBus.Instance); - public IEntityChangeEventHelper EntityChangeEventHelper { get; set; } + public IEntityChangeEventHelper EntityChangeEventHelper => LazyServiceProvider.LazyGetService(NullEntityChangeEventHelper.Instance); - public IAuditPropertySetter AuditPropertySetter { get; set; } + public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance); - public IGuidGenerator GuidGenerator { get; set; } + public IAuditPropertySetter AuditPropertySetter => LazyServiceProvider.LazyGetRequiredService(); public MemoryDbRepository(IMemoryDatabaseProvider databaseProvider) { DatabaseProvider = databaseProvider; - - LocalEventBus = NullLocalEventBus.Instance; - DistributedEventBus = NullDistributedEventBus.Instance; - EntityChangeEventHelper = NullEntityChangeEventHelper.Instance; } protected override IQueryable GetQueryable() diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index 109aeac8cd..43fdf4649b 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -37,29 +37,24 @@ namespace Volo.Abp.Domain.Repositories.MongoDB protected IMongoDbContextProvider DbContextProvider { get; } - public ILocalEventBus LocalEventBus { get; set; } + public ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetService(NullLocalEventBus.Instance); - public IDistributedEventBus DistributedEventBus { get; set; } + public IDistributedEventBus DistributedEventBus => LazyServiceProvider.LazyGetService(NullDistributedEventBus.Instance); - public IEntityChangeEventHelper EntityChangeEventHelper { get; set; } + public IEntityChangeEventHelper EntityChangeEventHelper => LazyServiceProvider.LazyGetService(NullEntityChangeEventHelper.Instance); - public IGuidGenerator GuidGenerator { get; set; } + public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance); - public IAuditPropertySetter AuditPropertySetter { get; set; } + public IAuditPropertySetter AuditPropertySetter => LazyServiceProvider.LazyGetRequiredService(); - public IMongoDbBulkOperationProvider BulkOperationProvider { get; set; } + public IMongoDbBulkOperationProvider BulkOperationProvider => LazyServiceProvider.LazyGetService(); public MongoDbRepository(IMongoDbContextProvider dbContextProvider) { DbContextProvider = dbContextProvider; - - LocalEventBus = NullLocalEventBus.Instance; - DistributedEventBus = NullDistributedEventBus.Instance; - EntityChangeEventHelper = NullEntityChangeEventHelper.Instance; - GuidGenerator = SimpleGuidGenerator.Instance; } - public async override Task InsertAsync( + public override async Task InsertAsync( TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) @@ -113,7 +108,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB } } - public async override Task UpdateAsync( + public override async Task UpdateAsync( TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) @@ -216,7 +211,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB } } - public async override Task DeleteAsync( + public override async Task DeleteAsync( TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) @@ -346,17 +341,17 @@ namespace Volo.Abp.Domain.Repositories.MongoDB } } - public async override Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) + public override async Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) { return await GetMongoQueryable().ToListAsync(GetCancellationToken(cancellationToken)); } - public async override Task GetCountAsync(CancellationToken cancellationToken = default) + public override async Task GetCountAsync(CancellationToken cancellationToken = default) { return await GetMongoQueryable().LongCountAsync(GetCancellationToken(cancellationToken)); } - public async override Task> GetPagedListAsync( + public override async Task> GetPagedListAsync( int skipCount, int maxResultCount, string sorting, @@ -370,7 +365,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB .ToListAsync(GetCancellationToken(cancellationToken)); } - public async override Task DeleteAsync( + public override async Task DeleteAsync( Expression> predicate, bool autoSave = false, CancellationToken cancellationToken = default) @@ -390,7 +385,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB return GetMongoQueryable(); } - public async override Task FindAsync( + public override async Task FindAsync( Expression> predicate, bool includeDetails = true, CancellationToken cancellationToken = default)