有什么办法可以让 NHibernate 使用吗the READPAST hint https://learn.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table从 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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)