- 增加 ISelect.ForUpdate 排他更新锁(根据数据库类型的规则,见代码注释);

- 完善 SqlServer WithLock 功能,组合多种使用 | 枚举相联;
This commit is contained in:
28810
2019-12-14 11:43:17 +08:00
parent 655d19153b
commit 15c3ab7297
32 changed files with 470 additions and 170 deletions

View File

@ -1525,5 +1525,21 @@ namespace FreeSql.Tests.Odbc.Oracle
Assert.Equal(5, g.oracle.Select<ToUpd3Pk>().Count());
Assert.Equal(5, g.oracle.Select<ToUpd3Pk>().Where(a => a.name.StartsWith("nick")).Count());
}
[Fact]
public void ForUpdate()
{
var orm = g.oracle;
orm.Transaction(() =>
{
var sql = orm.Select<ToUpd1Pk>().ForUpdate().Limit(1).ToSql().Replace("\r\n", "");
Assert.Equal("SELECT a.\"ID\", a.\"NAME\" FROM \"TOUPD1PK\" a WHERE ROWNUM < 2 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 WHERE ROWNUM < 2 for update nowait", sql);
orm.Select<ToUpd1Pk>().ForUpdate(true).Limit(1).ToList();
});
}
}
}