Reputation: 1781
This is a WPF app. I use one session per presenter. The user navigates from one presenter to another but usually no more than 2 levels deep:
How can I solve this scenario?
Upvotes: 3
Views: 491
Reputation: 164291
This happens because the Session includes what is commonly referred to as the first-level cache. It simply contains all entities the Session has "seen" during it's lifespan, in order to avoid re-fetching them from the database.
You can use session.Clear()
to clear the session before making any queries. If you do this in your presenter after each navigation action, you should be OK.
Another approach is to define a SessionManager class that manages your Session so the two presenters share their Session. This might be the best solution, if you can find some way to define the lifespan of one Session (I wouldn't recommend keeping the same Session around for the entire program execution).
Upvotes: 3