﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Arnis Lapsa commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>Now that's a really good tip!
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment13</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment13</guid><pubDate>Tue, 12 Apr 2011 14:41:04 GMT</pubDate></item><item><title>bill commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>+1 for a view model. unless you're app is intended  to be a super simple layer over db crud off course.
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment12</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment12</guid><pubDate>Mon, 11 Apr 2011 10:19:18 GMT</pubDate></item><item><title>Dominic Pettifer commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@Alwin
  
  
Well spotted, I didn't see that :-)
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment11</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment11</guid><pubDate>Fri, 08 Apr 2011 14:53:15 GMT</pubDate></item><item><title>joe commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>I'm still up in the air on how I'm going to handle session scope in my next project. It's nice to have it open in view for child actions, but this can lead to many select N+1 in view code if you're too lazy to map a domain object to viewmodel. Child actions are just sooo convenient for a complex site.master menu...so, it really comes down to not being lazy with your view models.
  
  
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment10</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment10</guid><pubDate>Fri, 08 Apr 2011 14:31:44 GMT</pubDate></item><item><title>Alwin commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>Look at the right, Future Post number 2 :) 
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment9</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment9</guid><pubDate>Fri, 08 Apr 2011 14:26:25 GMT</pubDate></item><item><title>Adam commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@Scooletz Thanks, that makes sense
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment8</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment8</guid><pubDate>Fri, 08 Apr 2011 13:46:31 GMT</pubDate></item><item><title>Dominic Pettifer commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>Not sure I agree with the approach (in fact I don't), there are better ways to solve the Select N + 1 problem, such as strongly typed ViewModels. Plus in real world apps I build, I'm rarely sending just a collection domain models/entities to the View, it usually includes a bunch of other things, hence the argument for ViewModels.
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment7</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment7</guid><pubDate>Fri, 08 Apr 2011 13:45:28 GMT</pubDate></item><item><title>Scooletz commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@Adam,
  
Items are held by current request, so as far as I see your point: not, there can be no cross-request problem.
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment6</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment6</guid><pubDate>Fri, 08 Apr 2011 13:28:29 GMT</pubDate></item><item><title>Adam commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>Sorry if this sounds thick, but is there a danger of overlapping requests sharing the same session and one disposing a session that is still being used? If that makes sense?
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment5</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment5</guid><pubDate>Fri, 08 Apr 2011 13:20:00 GMT</pubDate></item><item><title>Scooletz commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@Ryan,
  
yes, you're right! The child actions are executed when a parent's action result is executed. Your ordering is right. It does not change the fact, that first level cache optimization is lost, and that was the point behind my comment :) 
  
  
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment4</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment4</guid><pubDate>Fri, 08 Apr 2011 13:09:14 GMT</pubDate></item><item><title>Ryan Heath commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@Scooletz
  
  
I think each child action creates its own session and disposes it. Also the parent action disposes its own session.
  
Because when child actions are invoked from the view the parent action has already disposed its session.
  
  
The sequence is like:
  
- parent OnActionExecuting
  
- parent Action
  
- parent OnActionExecuted
  
- viewResult is executed: any child action in the view goes through the same sequence.
  
  
// Ryan
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment3</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment3</guid><pubDate>Fri, 08 Apr 2011 12:35:20 GMT</pubDate></item><item><title>Scooletz commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>@François
  
Of course it is not. The scenario goes like:
  
- parent action creates and stores a session in a context
  
- child action creates and overrides parent's session in a context
  
- child action disposes the session
  
- the parent action is left with a handful of nothing, a disposed session.
  
  
The better solution is to use http modules with Castle disposing module (at the end of a request). It is fired once, at the end of parent request and allows you to use the same session (first level cache).
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment2</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment2</guid><pubDate>Fri, 08 Apr 2011 10:37:45 GMT</pubDate></item><item><title>Fran&amp;#231;ois commented on Refactoring toward frictionless &amp; odorless code: Limiting session scope</title><description>This implies we'll have different sessions for child actions. Is this benign?
  
  
The good point is thanks to the new ASP.Net MVC 3 Global Filters, we won't have to decorate every controller with the NHibernateActionFilterAttribute.
</description><link>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment1</link><guid>http://ayende.com/4805/refactoring-toward-frictionless-odorless-code-limiting-session-scope#comment1</guid><pubDate>Fri, 08 Apr 2011 09:46:11 GMT</pubDate></item></channel></rss>