3

我正在为我的 webmatrix 项目编写代码,其中应用了事务提交和回滚。我正在使用 mysql 5.1 和 innodb 数据库引擎来支持事务。

我用

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类可以实现吗?

4

1 回答 1

2

DatabaseWebMatrix.Data事务支持方面不提供任何东西。它的设计目的是让初学者更容易上手 ASP.NET。如果您想在网页站点中使用事务,您可以使用纯 ADO.NET 代码进行数据访问,或者您可以使用内置事务支持的实体框架之类的东西。

于 2015-12-09T13:51:22.107 回答