public TDbContext CreateDbContext <TDbContext>(IDbContextScopeBase dbContextScope, bool readOnly) where TDbContext : DbContext
        {
            var interceptor = readOnly
        ? _dbContextReadOnlyInterceptor
        : _dbContextInterceptor;

            var proxyGenerationOptions      = new ProxyGenerationOptions(interceptor);
            var constructorArgs             = _ambientDbContextArgumentFactory.CreateDbContextArguments <TDbContext>();
            var additionalInterfacesToProxy = new[] { typeof(IDbContextProxyBypass) };
            var proxy = (TDbContext)proxyGenerator.CreateClassProxy(typeof(TDbContext), additionalInterfacesToProxy, proxyGenerationOptions, constructorArgs, interceptor);

            return(proxy);
        }
Exemple #2
0
 public TDbContext CreateDbContext <TDbContext>(IDbContextScopeBase dbContextScope, bool readOnly) where TDbContext : DbContext
 {
     return(Activator.CreateInstance <TDbContext>());
 }