有什么办法可以让 NHibernate 使用 the READPAST
hint从 SQL Server 选择数据时?
最佳答案
选项#1简单方法:SQL查询
Session.CreateSQLQuery("select * from YourEntityTable with (readpast) where SomeColumn = :col")
.AddEntity(typeof(YourEntity))
.SetString("col", value)
.UniqueResult<YourEntity>();
选项 #2 需要更多工作:
如果您不使用 NHibernate.LockMode 之一,您可以将方言的 AppendLockHint() 重写为:
public override string AppendLockHint(LockMode lockMode, string tableName)
{
if (lockMode == <lockModeYouWantToSacrificeForThis>)
{
return tableName + " with (readpast)";
}
return tableName;
}
关于sql-server - 如何在 NHibernate 中使用 READPAST 提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5104695/