Christian Mikkelsen
Christian Mikkelsen

Reputation: 1701

Query NHibernate Cache

Is there a way to check if an entity is allready in the cache of NHB (no 2nd level cache enabled) when only the database primary key/Id is known, without hitting the DB as one would if using Get?

In short something down the lines of:

 _session.ExistsInCache()

Kind regards

Upvotes: 0

Views: 52

Answers (1)

Diego Mijelshon
Diego Mijelshon

Reputation: 52745

This is one way...

var exists = NHibernateUtil.IsInitialized(Session.Load<YourClass>(id));

Upvotes: 2

Related Questions