Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 18, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/6e90fb8abacc639090371ef891856f3b to your computer and use it in GitHub Desktop.
Save dcomartin/6e90fb8abacc639090371ef891856f3b to your computer and use it in GitHub Desktop.
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{
var modifiedProducts = base.ChangeTracker.Entries<ProductModel>()
.Where(x => x.State == EntityState.Modified)
.Select(entry => new ProductModified {ProductId = entry.Entity.Id})
.ToArray();
var result = await base.SaveChangesAsync(cancellationToken);
await _messageBus.Publish(modifiedProducts);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment