You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All entities have a common base type, which is Object. Imagine we want to log what Entity got changed and when:
publicclassLogTrigger:IAfterSaveTrigger<object>{readonlyIApplicationDbContext_applicationDbContext;publicLogTrigger(ApplicationDbContextapplicationDbContext){_applicationDbContext=applicationDbContext;}publicTaskAfterSave(ITriggerContext<object>context,CancellationTokencancellationToken){varentry=_applicationDbContext.ChangeTracker.Entry(context.Entity);varkeyString=string.Join(", ",entry.Metadata.FindPrimaryKey().Properties.Select(p =>entry.Property(p.Name).CurrentValue));Console.WriteLine($"Detected {context.ChangeType} on a {context.Entity.GetType().Name} with id: {keyString}");}}