Beispiel #1
0
        public static T WithDataManager <T>(this IDataManagerFactory factory, Func <IDataManager, T> func, IsolationLevel?level = null)
        {
            using (var manager = level == null ? factory.GetManager() : factory.GetTransactionManager(level.Value))
            {
                var result = func(manager);

                var transaction = manager as IUnitOfWork;
                if (transaction != null)
                {
                    transaction.Commit();
                }

                return(result);
            }
        }