2015-12-05 45 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代碼來訪問數據,也可以使用內置事務支持的實體框架。