如何在NHibernate中使用READPAST提示?

有什么办法可以让NHibernate在从SQL Server中选择数据时使用
READPAST
提示吗?     
已邀请:
选项#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;
}
    

要回复问题请先登录注册