Пример #1
0
        /// <summary>
        ///     Returns InstanceProxy[TObjectContext] for ObjectContext instance that already exist.
        ///     Returned proxy won't call ObjectContext.Dispose() after method invocation.
        ///     Supports ExecuteCommand() method.
        /// </summary>
        /// <typeparam name="TObjectContext"></typeparam>
        /// <param name="existingOcContext"></param>
        /// <param name="aspects"></param>
        /// <returns></returns>
        public static ObjectContextSingleCallProxy <TObjectContext> GetOcProxy <TObjectContext>(this TObjectContext existingOcContext, IEnumerable <Aspect> aspects = null)
            where TObjectContext : ObjectContext, new()
        {
            var proxy = new ObjectContextSingleCallProxy <TObjectContext>(existingOcContext, aspects);

            return(proxy);
        }
Пример #2
0
        /// <summary>
        ///     Returns AOP proxy for EF ObjectContext class
        /// </summary>
        /// <typeparam name="TObjectContext"></typeparam>
        /// <param name="aspects"></param>
        /// <param name="lazyLoadingEnabled"></param>
        /// <returns></returns>
        public static ObjectContextSingleCallProxy <TObjectContext> GetOcProxy <TObjectContext>(IEnumerable <Aspect> aspects = null, bool lazyLoadingEnabled = true)
            where TObjectContext : ObjectContext, new()
        {
            var proxy = new ObjectContextSingleCallProxy <TObjectContext>(aspects, lazyLoadingEnabled);

            return(proxy);
        }