From 11894c822579f9796268a317e127692eed9f050a Mon Sep 17 00:00:00 2001 From: "BRUCE.L" Date: Thu, 6 Apr 2023 17:50:23 -0700 Subject: [PATCH] Override SaveChangesAsync --- src/Wax.Core/Data/ApplicationDbContext.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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;