/// <summary> /// Returns InstanceProxy[TDbContext] for DbContext instance that already exist. /// Returned proxy won't call DbContext.Dispose() after method invocation. /// Supports ExecuteCommand() method. /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="dbExistingContext"></param> /// <param name="aspects"></param> /// <param name="autoDispose">If true, Dispose() will be called after the end of the intercepted call.</param> /// <returns></returns> public static DbContextSingleCallProxy <TDbContext> GetDbProxy <TDbContext>(this TDbContext dbExistingContext, IEnumerable <Aspect> aspects = null, bool autoDispose = false) where TDbContext : DbContext, new() { var proxy = new DbContextSingleCallProxy <TDbContext>(dbExistingContext, aspects, autoDispose); return(proxy); }
/// <summary> /// Returns AOP proxy for EF DbContext class that will instantiate DbContext and after usage calls DbContext.Dispose() /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="aspects"></param> /// <param name="lazyLoadingEnabled"></param> /// <returns></returns> public static DbContextSingleCallProxy <TDbContext> GetDbProxy <TDbContext>(IEnumerable <Aspect> aspects = null, bool lazyLoadingEnabled = true) where TDbContext : DbContext, new() { var proxy = new DbContextSingleCallProxy <TDbContext>(aspects, lazyLoadingEnabled); return(proxy); }