示例#1
0
 protected void Transaction(Action <BlogCompilerContext> action)
 {
     using (var context = new BlogCompilerContext())
     {
         using (var transaction = new TransactionScope())
         {
             try
             {
                 action(context);
                 transaction.Complete();
             }
             catch (Exception e)
             {
                 throw e;
             }
         }
     }
 }
示例#2
0
 protected IList <T> Transaction <T>(Func <BlogCompilerContext, IList <T> > action)
 {
     using (var context = new BlogCompilerContext())
     {
         using (var transaction = new TransactionScope())
         {
             try
             {
                 var ret = action(context);
                 transaction.Complete();
                 return(ret);
             }
             catch (Exception e)
             {
                 throw e;
             }
         }
     }
 }