使用Nhibernate获取表锁(MyIsam)

时间:2011-07-11 07:34:49

标签: c# mysql nhibernate

使用Nhibernate如何获得“TABLE LOCKS”

我想做的是这样的事情:

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

1 个答案:

答案 0 :(得分:1)

在查询之前运行此功能:

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

之后相应的UNLOCK。