private void AttachHooks(IHook[] hooks) { if (hooks == null) { InitializeHooks(); return; }; PreHooks = hooks.OfType<IPreActionHook>().ToList(); PostHooks = hooks.OfType<IPostActionHook>().ToList(); PostLoadHooks = hooks.OfType<IPostLoadHook>().ToList(); }
public HookedDbContext(IHook[] hooks) { PreHooks = hooks.OfType<IPreActionHook>().ToList(); PostHooks = hooks.OfType<IPostActionHook>().ToList(); }
public HookedDbContext(IHook[] hooks, string nameOrConnectionString) : base(nameOrConnectionString) { PreHooks = hooks.OfType<IPreActionHook>().ToList(); PostHooks = hooks.OfType<IPostActionHook>().ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="HookedDbContext" /> class using the an existing connection to connect /// to a database. The connection will not be disposed when the context is disposed. (see <see cref="DbContext"/> overloaded constructor) /// </summary> /// <param name="hooks">The hooks.</param> /// <param name="existingConnection">An existing connection to use for the new context.</param> /// <param name="contextOwnsConnection">If set to true the connection is disposed when the context is disposed, otherwise the caller must dispose the connection.</param> /// <remarks>Main reason for allowing this, is to enable reusing another database connection. (For instance one that is profiled by Miniprofiler (http://miniprofiler.com/)).</remarks> public HookedDbContext(IHook[] hooks, DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection) { PreHooks = hooks.OfType<IPreActionHook>().ToList(); PostHooks = hooks.OfType<IPostActionHook>().ToList(); }