diff --git a/src/Wax.Core/Data/ApplicationDbContext.cs b/src/Wax.Core/Data/ApplicationDbContext.cs index d5df857..c73afab 100644 --- a/src/Wax.Core/Data/ApplicationDbContext.cs +++ b/src/Wax.Core/Data/ApplicationDbContext.cs @@ -9,6 +9,8 @@ public ApplicationDbContext(DbContextOptions options) : ba { } + public bool HasEntitiesChanged { get; private set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseInMemoryDatabase("__wax_database"); @@ -18,9 +20,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(typeof(CustomerEntityTypeConfiguration).Assembly); } - - public bool HasEntitiesChanged { get; private set; } - + + + public override Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) + { + var result = base.SaveChangesAsync(cancellationToken); + + HasEntitiesChanged = false; + + return result; + } + public async Task ChangeEntitiesAsync(bool saveNow = false, CancellationToken cancellationToken = default) { HasEntitiesChanged = true;