Question

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)?

Était-ce utile?

La solution

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

using (ISessionFactory sf = cfg.BuildSessionFactory())
using (IStatelessSession session = sf.OpenStatelessSession())
{
    // ...
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top