NHibernate 3 Linq Cache

I just started using LINQ with NHibernate in NHibernate 3, after I used ICriteria before.

Here is an example request:

ISession session = NHibernateSessionManager.Instance.GetSession();

var results = from project in session.Query<Project>()
              where project.ProjectState == ProjectState.Archive
              orderby project.ProjectNumber
              select project;

return results.ToList();

How to install caching? I looked around, and other questions seem to use a different (maybe outdated?) Syntax, or maybe I'm doing it wrong ...

+5
source share
1 answer

Use the extension method Cacheable()on your Queryable before calling ToList().

+9
source

All Articles