Tutorial :Avoid first level cache for an entity in NHibernate?


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


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

using (ISessionFactory sf = cfg.BuildSessionFactory())  using (IStatelessSession session = sf.OpenStatelessSession())  {      // ...  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »