Exemplo n.º 1
0
        public static async Task TransactionalOperationAsync(Func <Task> func)
        {
            try
            {
                using (var dbContext = REAUDbContext.CreateDefaultSerializationContext())
                {
                    await func();

                    dbContext.Complete();
                }
            }
            catch (Exception ex)
            {
                // log ex
                throw;
            }
        }
Exemplo n.º 2
0
        public static async Task <T> TransactionalOperationAsync <T>(Func <Task <T> > func)
        {
            T res = default(T);

            try
            {
                using (var dbContext = REAUDbContext.CreateDefaultSerializationContext())
                {
                    res = await func();

                    dbContext.Complete();
                }
            }
            catch (Exception ex)
            {
                // log ex
                throw;
            }

            return(res);
        }