-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove DomainEventUnitOfWorkBehavior,不支持在domainEvent中处理事务
- Loading branch information
1 parent
d1ff8c1
commit a706a8d
Showing
3 changed files
with
47 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<VersionPrefix>1.0.2</VersionPrefix> | ||
<VersionPrefix>1.0.3</VersionPrefix> | ||
<VersionSuffix></VersionSuffix> | ||
</PropertyGroup> | ||
</Project> |
87 changes: 44 additions & 43 deletions
87
src/Repository.EntityFrameworkCore/Behaviors/DomainEventUnitOfWorkBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
using MediatR; | ||
using NetCorePal.Extensions.Domain; | ||
using NetCorePal.Extensions.Primitives; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NetCorePal.Extensions.Repository.EntityFrameworkCore | ||
{ | ||
|
||
internal class DomainEventUnitOfWorkBehavior<TDomanEvent, TResponse> : IPipelineBehavior<TDomanEvent, TResponse> where TDomanEvent : IDomainEvent | ||
{ | ||
private readonly ITransactionUnitOfWork _unitOfWork; | ||
public DomainEventUnitOfWorkBehavior(ITransactionUnitOfWork unitOfWork) | ||
{ | ||
_unitOfWork = unitOfWork; | ||
} | ||
|
||
|
||
public async Task<TResponse> Handle(TDomanEvent request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken) | ||
{ | ||
if (_unitOfWork.CurrentTransaction != null) | ||
{ | ||
var response = await next(); | ||
await _unitOfWork.SaveEntitiesAsync(cancellationToken); | ||
return response; | ||
} | ||
|
||
|
||
using (var transaction = _unitOfWork.BeginTransaction()) | ||
{ | ||
var response = await next(); | ||
await _unitOfWork.SaveEntitiesAsync(cancellationToken); | ||
await _unitOfWork.CommitAsync(cancellationToken); | ||
return response; | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
// using MediatR; | ||
Check warning on line 1 in src/Repository.EntityFrameworkCore/Behaviors/DomainEventUnitOfWorkBehavior.cs GitHub Actions / build
Check warning on line 1 in src/Repository.EntityFrameworkCore/Behaviors/DomainEventUnitOfWorkBehavior.cs GitHub Actions / build
Check warning on line 1 in src/Repository.EntityFrameworkCore/Behaviors/DomainEventUnitOfWorkBehavior.cs GitHub Actions / build
|
||
// using NetCorePal.Extensions.Domain; | ||
// using NetCorePal.Extensions.Primitives; | ||
// using System; | ||
// using System.Collections.Generic; | ||
// using System.Linq; | ||
// using System.Text; | ||
// using System.Threading.Tasks; | ||
// | ||
// namespace NetCorePal.Extensions.Repository.EntityFrameworkCore | ||
// { | ||
// | ||
// | ||
// internal class DomainEventUnitOfWorkBehavior<TDomanEvent, TResponse> : IPipelineBehavior<TDomanEvent, TResponse> where TDomanEvent : IDomainEvent | ||
// { | ||
// private readonly ITransactionUnitOfWork _unitOfWork; | ||
// public DomainEventUnitOfWorkBehavior(ITransactionUnitOfWork unitOfWork) | ||
// { | ||
// _unitOfWork = unitOfWork; | ||
// } | ||
// | ||
// | ||
// public async Task<TResponse> Handle(TDomanEvent request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken) | ||
// { | ||
// if (_unitOfWork.CurrentTransaction != null) | ||
// { | ||
// var response = await next(); | ||
// await _unitOfWork.SaveEntitiesAsync(cancellationToken); | ||
// return response; | ||
// } | ||
// | ||
// | ||
// using (var transaction = _unitOfWork.BeginTransaction()) | ||
// { | ||
// var response = await next(); | ||
// await _unitOfWork.SaveEntitiesAsync(cancellationToken); | ||
// await _unitOfWork.CommitAsync(cancellationToken); | ||
// return response; | ||
// } | ||
// } | ||
// } | ||
// | ||
// | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters