http://terrylee.vcblog.net/archive/2006/06/24/368471.html

 using(TransactionScope tran = new TransactionScope())
    {
        
try
        {           
            
for(int i=1;i<5;i++)
            {
                
//创建Post对象
                Post post = new Post();
                post.Title
="This is my "+i.ToString()+" post";
                post.Category
="Castle";
                
                
//注释掉这句
                
//post.Save();
                
                blog.Posts.Add(post);
            }
 
            blog.Update();
            
        tran.VoteCommit();
        }
        
catch
        {
            tran.VoteRollBack();
        }
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
猜你喜欢
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案