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开发者_如何学Python
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...
Use the Cacheable()
extension method on your Queryable before calling ToList()
.
精彩评论