2015-12-05 42 views
2

我正在为应用事务提交和回滚的webmatrix项目编写代码。 我使用mysql 5.1和innodb数据库引擎进行事务支持。如何在Webmatrix.Data.Database中创建事务提交和回滚

我用

db.Connection.BeginTransaction(); 
       try 
       { 
        db.Execute("Insert into tmp_upload_img(`path`,`type`) values(@0)", FullPath,"Fullimage"); 
        db.Execute("Insert into tmp_upload_img(`path`,`type`) values(@0)", ThumbPath, "Thumbimage"); 
        db.Execute("Insert into tmp_upload_img(`path`,`type`) values(@0)", SmallPath, "Smallimage"); 
        db.Connection.BeginTransaction().Commit(); 
       } 
       catch 
       { 
        db.Connection.BeginTransaction().Rollback(); 
       } 

,可是我不实现WebMatrix的项目事务支持。

我知道这可以mysql.data.mysqlclient实现,但我想知道这是可能的webmatrix.data类?

回答

0

WebMatrix.Data中的Database类没有提供任何支持交易的方面。它旨在让初学者能够轻松使用ASP.NET。如果要在Web页面中使用事务,则可以使用普通的ADO.NET代码来访问数据,也可以使用内置事务支持的实体框架。