views:

249

answers:

2

I was using regular session for loading some items from database via linq. The problem is that it caches the entities and memory load increases very much unnecessarily. Is there a way to replace session with stateless session without introducing many changes in client code?

+1  A: 

It's not possible to use Linq with IStatelessSession.

You can use all the other query methods (Get, Criteria, HQL and SQL).

Update (2010-07-19): I believe Steve might be adding this to the NH 3.x provider)

Diego Mijelshon
A: 

Have you got lazy loading turned on?

I don't have any experience with LINQ to NHibernate, but in my application, lazy loading makes a huge difference in performance.

Tom Bushell
The problem is hight memory consumption. During memory profiling I found out that memory is not released by garbage collector. The problem turned to be first level caching which cannot be disabled. Memory is cleaned though after session is closed.
Jenea