Browse Source

Try to `GetEventsRecords` after `SaveChangesAsync`.

This problem was introduced from https://github.com/abpframework/abp/pull/21211
pull/21320/head
maliming 1 year ago
parent
commit
86b14043cf
  1. 6
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
  2. 5
      framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs

6
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs

@ -630,14 +630,8 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext,
originalExtraProperties = entry.OriginalValues.GetValue<ExtraPropertyDictionary>(nameof(IHasExtraProperties.ExtraProperties));
}
//TODO: Reload will throw an exception. Check it when new EF Core versions released.
entry.Reload();
// var storeValues = entry.OriginalValues;
// entry.CurrentValues.SetValues(storeValues);
// entry.OriginalValues.SetValues(storeValues);
// entry.State = EntityState.Unchanged;
if (entry.Entity is IHasExtraProperties)
{
ObjectHelper.TrySetProperty(entry.Entity.As<IHasExtraProperties>(), x => x.ExtraProperties, () => originalExtraProperties);

5
framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs

@ -152,7 +152,6 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency
await UnitOfWorkEventPublisher.PublishLocalEventsAsync(
localEventsToBePublished
);
LocalEvents.AddRange(GetEventsRecords(LocalEventWithPredicates));
}
if (DistributedEvents.Any())
@ -163,10 +162,12 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency
await UnitOfWorkEventPublisher.PublishDistributedEventsAsync(
distributedEventsToBePublished
);
DistributedEvents.AddRange(GetEventsRecords(DistributedEventWithPredicates));
}
await SaveChangesAsync(cancellationToken);
LocalEvents.AddRange(GetEventsRecords(LocalEventWithPredicates));
DistributedEvents.AddRange(GetEventsRecords(DistributedEventWithPredicates));
}
await CommitTransactionsAsync(cancellationToken);

Loading…
Cancel
Save