Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using nHibernate, how can I read uncommited?

Tags:

nhibernate

Using nhibernate, how can I set the transaction level to read uncommitted?

With SQL, I usually set the transaction level at teh beginning of my stored procedure or use inline (NOLOCK).

like image 986
Blankman Avatar asked Jun 01 '09 21:06

Blankman


1 Answers

You can use nolock in-line SQLs with nhibernate by using following steps:

  1. Create HBM File with following

    <sql-query name="PersonList">
    return alias="person"  class="Person">
    SELECT * FROM Person WITH(nolock) 
    <sql-query>
    
  2. Use AddXmlFile(hbm file path) while creating nhibernate session.

  3. Using DBSession.GetNamedQuery("PersonList") get the list of persons.

like image 179
NitinT Avatar answered Oct 23 '22 03:10

NitinT