NHibernate 3 Linq query caching

2019-06-21 05:38发布

I've just started using LINQ with NHibernate in NHibernate 3, after previously using ICriteria.

Here's an example query:

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 do I set that to cache? I've had a look around and other questions seem to use a different (perhaps outdated?) syntax, or perhaps I'm doing it wrong...

1条回答
够拽才男人
2楼-- · 2019-06-21 06:17

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

查看更多
登录 后发表回答