public void OnAttaching(IAttachingService attachingService, object source, IEventsScope eventsScope) { if (source is TDbContext dbContext) { ((IObjectContextAdapter)dbContext).ObjectContext.ObjectMaterialized += (sender, args) => { attachingService.Attach(args.Entity, eventsScope); } } ; } }
public void OnAttaching(IAttachingService attachingService, object source, IEventsScope eventsScope) { if (source is TDbContext dbContext) { dbContext.ChangeTracker.Tracked += (sender, args) => { attachingService.Attach(args.Entry.Entity, eventsScope); } } ; } }
public void SetUp() { _sourceModelsServiceMock = new Mock <ISourceModelsService>(MockBehavior.Strict); _forwardingServiceMock = new Mock <IForwardingService>(MockBehavior.Strict); _attachingInterceptorMock1 = new Mock <IAttachingInterceptor>(MockBehavior.Strict); _attachingInterceptorMock2 = new Mock <IAttachingInterceptor>(MockBehavior.Strict); _eventsScopeMock = new Mock <IEventsScope>(MockBehavior.Strict); _attachingService = new AttachingService( _sourceModelsServiceMock.Object, _forwardingServiceMock.Object, new[] { _attachingInterceptorMock1.Object, _attachingInterceptorMock2.Object } ); }