Beispiel #1
0
        public static ResetLazy <T> WithoutInvalidations <T>(Func <T> func, LazyThreadSafetyMode mode = LazyThreadSafetyMode.ExecutionAndPublication) where T : class
        {
            ResetLazy <T> result = new ResetLazy <T>(() =>
            {
                using (ExecutionMode.Global())
                    using (HeavyProfiler.Log("ResetLazy", () => typeof(T).TypeName()))
                        using (Transaction tr = Transaction.InTestTransaction ? null : Transaction.ForceNew())
                            using (new EntityCache(EntityCacheType.ForceNewSealed))
                            {
                                var value = func();

                                if (tr != null)
                                {
                                    tr.Commit();
                                }

                                return(value);
                            }
            }, mode,
                                                     declaringType: func.Method.DeclaringType);

            registeredLazyList.Add(result);

            return(result);
        }