I need to know a way to implement in my system, a Driver or Dialect which, whenever I perform a SELECT in Nhibernate, the SELECT adds the with(nolock) with it. I need that t
It is possible to modify the sql using an Interceptor and overriding the OnPrepareStatement method, something like this:
public class AddNoLockHintsInterceptor : EmptyInterceptor
{
public override SqlString OnPrepareStatement(SqlString sql)
{
// Modify the sql to add hints
return sql;
}
}
And here is a way to register the interceptor with NHibernate:
var session = SessionFactory.OpenSession(new AddNoLockHintsInterceptor());