Skip to content

Instantly share code, notes, and snippets.

@dcomartin

dcomartin/DbContext.cs Secret

Created Nov 18, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.