Commit 2f5c7d8c by dingsongjie

统一 entityframework 和 ReliableMessage 的 UintOfWork

parent 93236c4c
...@@ -26,8 +26,7 @@ namespace Product.Api.Application.CommandHandler ...@@ -26,8 +26,7 @@ namespace Product.Api.Application.CommandHandler
public async Task<CommonCommandResponse> Handle(Command<AddProductTypeRequest, CommonCommandResponse> request, CancellationToken cancellationToken) public async Task<CommonCommandResponse> Handle(Command<AddProductTypeRequest, CommonCommandResponse> request, CancellationToken cancellationToken)
{ {
var productType = new Domain.ProductTypeAggregate.ProductType(request.Data.Id, request.Data.Name); var productType = new Domain.ProductTypeAggregate.ProductType(request.Data.Id, request.Data.Name);
_productTypeRepository.Add(productType); _productTypeRepository.Add(productType);
ProductTypeAddedDomainEvent productTypeAddedDomainEvent = new ProductTypeAddedDomainEvent ProductTypeAddedDomainEvent productTypeAddedDomainEvent = new ProductTypeAddedDomainEvent
{ {
......
...@@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection ...@@ -21,7 +21,7 @@ namespace Microsoft.Extensions.DependencyInjection
} }
public static PoleOptions AutoInjectionDependency(this PoleOptions options) public static PoleOptions AutoInjectionDependency(this PoleOptions options)
{ {
var assemblies = options.ApplicationAssemblies; var assemblies = options.ApplicationAssemblies??throw new Exception("Cant't find ApplicationAssemblies,You must Run PoleOptions.AddManageredAssemblies First");
foreach (var assembly in assemblies) foreach (var assembly in assemblies)
{ {
...@@ -34,10 +34,11 @@ namespace Microsoft.Extensions.DependencyInjection ...@@ -34,10 +34,11 @@ namespace Microsoft.Extensions.DependencyInjection
public static PoleOptions AutoInjectionCommandHandlersAndDomainEventHandlers(this PoleOptions options, ServiceLifetime lifetime = ServiceLifetime.Scoped) public static PoleOptions AutoInjectionCommandHandlersAndDomainEventHandlers(this PoleOptions options, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{ {
var assemblies = options.ApplicationAssemblies ?? throw new Exception("Cant't find ApplicationAssemblies,You must Run PoleOptions.AddManageredAssemblies First");
options.Services.AddMediatR(config => options.Services.AddMediatR(config =>
{ {
config.AddServiceLifetime(lifetime); config.AddServiceLifetime(lifetime);
}, options.ApplicationAssemblies.ToArray()); }, assemblies.ToArray());
return options; return options;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment