从SQL Server中选择数据时,有没有办法让NHibernate使用the READPAST
hint?
答案 0 :(得分:2)
Session.CreateSQLQuery("select * from YourEntityTable with (readpast) where SomeColumn = :col")
.AddEntity(typeof(YourEntity))
.SetString("col", value)
.UniqueResult<YourEntity>();
如果你没有使用NHibernate.LockMode,你可以将dialect的AppendLockHint()覆盖为:
public override string AppendLockHint(LockMode lockMode, string tableName)
{
if (lockMode == <lockModeYouWantToSacrificeForThis>)
{
return tableName + " with (readpast)";
}
return tableName;
}