mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 ISelect.ForUpdate 排他更新锁(根据数据库类型的规则,见代码注释);
- 完善 SqlServer WithLock 功能,组合多种使用 | 枚举相联;
This commit is contained in:
@ -1598,5 +1598,21 @@ namespace FreeSql.Tests.MySqlConnector
|
||||
Assert.Equal(5, g.mysql.Select<ToUpd3Pk>().Count());
|
||||
Assert.Equal(5, g.mysql.Select<ToUpd3Pk>().Where(a => a.name.StartsWith("nick")).Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ForUpdate()
|
||||
{
|
||||
var orm = g.mysql;
|
||||
orm.Transaction(() =>
|
||||
{
|
||||
var sql = orm.Select<ToUpd1Pk>().ForUpdate().Limit(1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`id`, a.`name` FROM `ToUpd1Pk` a limit 0,1 for update", sql);
|
||||
orm.Select<ToUpd1Pk>().ForUpdate().Limit(1).ToList();
|
||||
|
||||
sql = orm.Select<ToUpd1Pk>().ForUpdate(true).Limit(1).ToSql().Replace("\r\n", "");
|
||||
Assert.Equal("SELECT a.`id`, a.`name` FROM `ToUpd1Pk` a limit 0,1 for update", sql);
|
||||
orm.Select<ToUpd1Pk>().ForUpdate(true).Limit(1).ToList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user