views:

24

answers:

1

I have an entity which is updated externally (using triggers, stored procedures). This means the entity can change without my knowledge in the same session, and it is required for me that I always perform a database hit, and never use the entity from the first level cache.

Is this possible using NHibernate (or actually, Castle ActiveRecord)?

+4  A: 

You cold use a IStatelessSession instead of ISession to disable first level cache:

using (ISessionFactory sf = cfg.BuildSessionFactory())
using (IStatelessSession session = sf.OpenStatelessSession())
{
    // ...
}
Darin Dimitrov
In ActiveRecord: StatelessSessionScope
Mauricio Scheffer