UnitOfWork完成后添加领域事件怎么办?
What should I do to add a domain event after the completion of UnitOfWork?
我使用了 ABP vNext framework.I 需要在将指定的聚合 属性 成功保存到数据库时发布域事件,但是现在,域事件总是在工作单元之前触发已完成。
代码
public class Meeting : AggregateRoot<Guid>{
public Meeting(Guid id, Guid applicantId) : base(id) {
ApplicantId = applicantId;
Phase = MeetingPhase.Draft;
Type = MeetingType.Default;
TimeAndPlaces = new Collection<TimeAndPlace>();
InsideAttendees = new Collection<InsideAttendee>();
MeetingFiles = new Collection<MeetingFile>();
}
/// <summary>
/// 取消会议
/// </summary>
public void Cancel() {
Phase = MeetingPhase.Draft;
Type = MeetingType.Canceled;
var cancelData = new MeetingCancelData(this);
AddLocalEvent(cancelData);
}
}
您可以为 IUnitOfWork.CompletedHandlers 个处理程序做出贡献。
我使用了 ABP vNext framework.I 需要在将指定的聚合 属性 成功保存到数据库时发布域事件,但是现在,域事件总是在工作单元之前触发已完成。
代码
public class Meeting : AggregateRoot<Guid>{
public Meeting(Guid id, Guid applicantId) : base(id) {
ApplicantId = applicantId;
Phase = MeetingPhase.Draft;
Type = MeetingType.Default;
TimeAndPlaces = new Collection<TimeAndPlace>();
InsideAttendees = new Collection<InsideAttendee>();
MeetingFiles = new Collection<MeetingFile>();
}
/// <summary>
/// 取消会议
/// </summary>
public void Cancel() {
Phase = MeetingPhase.Draft;
Type = MeetingType.Canceled;
var cancelData = new MeetingCancelData(this);
AddLocalEvent(cancelData);
}
}
您可以为 IUnitOfWork.CompletedHandlers 个处理程序做出贡献。