C# 使用Nhibernate获取表锁(MyIsam)

C# 使用Nhibernate获取表锁(MyIsam),c#,mysql,nhibernate,C#,Mysql,Nhibernate,使用Nhibernate如何获得“表锁” 我想做的是这样的事情: TABLE LOCKS table1; update counter= 1 + counter from table1 where id=1; select counter from table1 where id=1; UNLOCK TABLES; 只需在查询之前运行以下命令: var command = session.Connection.CreateCommand(); command.CommandText = "TA

使用Nhibernate如何获得“表锁”

我想做的是这样的事情:

TABLE LOCKS table1;
update counter= 1 + counter from table1 where id=1;
select counter from table1 where id=1;
UNLOCK TABLES;

只需在查询之前运行以下命令:

var command = session.Connection.CreateCommand();
command.CommandText = "TABLE LOCKS table1";
command.ExecuteNonQuery();

然后相应的解锁。

哎哟,抱歉,看起来MyIsam不支持事务。删除我的答案。谢谢!最后是我使用的:command.CommandText=“LOCK TABLES table1 WRITE”;