/// <summary> /// Initializes a new instance of the <see cref="HookedDbContext" /> class, using the specified <paramref name="nameOrConnectionString"/>, , filling <see cref="_hooks"/> and <see cref="_hooks"/>. /// </summary> /// <param name="hooks">The hooks.</param> /// <param name="nameOrConnectionString">The name or connection string.</param> public HookedDbContext(IHook[] hooks, string nameOrConnectionString) : base(nameOrConnectionString) { _hooks = hooks.Select(h => new HookDecorator { Hook = h }).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) { _hooks = hooks.Select(h => new HookDecorator { Hook = h }).ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="HookedDbContext" /> class, filling <see cref="_hooks"/> and <see cref="_hooks"/>. /// </summary> /// <param name="hooks">The hooks.</param> public HookedDbContext(IHook[] hooks) { _hooks = hooks.Select(h => new HookDecorator { Hook = h }).ToList(); }