﻿<?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>Jorgas commented on Do you need a framework?</title><description>zvolkov,
  
Even though your solution also was interesting it did include a nessecity to use both CastleWindsor and MVCContrib, so I think your way of doing things are a bit more involved and complicated (arguably).
  
  
However, one point was raised in the comments that at least I think is important. How does one achieve having this behavior, but only actually opening a session when needed? Not in every request? Even though the opening of a session is VERY lightweight, it would be nice to avoid it.
  
  
Any ideas anyone?
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment34</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment34</guid><pubDate>Wed, 02 Sep 2009 08:57:08 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Bunter,
  
Take a note that there is a big difference between a few cohesive frameworks and a lot of minor, unrelated, details.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment33</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment33</guid><pubDate>Sat, 08 Aug 2009 23:51:03 GMT</pubDate></item><item><title>Bunter commented on Do you need a framework?</title><description>You will still have to reference NHibernate. And depending on the database, DB libs as well. Having one additional lib with simple framework code for is is just adding ... another reference.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment32</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment32</guid><pubDate>Sat, 08 Aug 2009 22:50:50 GMT</pubDate></item><item><title>zvolkov commented on Do you need a framework?</title><description>I posted complete example here:
  
  
[zvolkov.com/.../...ASPNET-MVC-with-NHibernate.aspx](http://zvolkov.com/blog/post/2009/08/06/Easiest-way-to-hook-up-ASPNET-MVC-with-NHibernate.aspx)</description><link>http://ayende.com/4101/do-you-need-a-framework#comment31</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment31</guid><pubDate>Fri, 07 Aug 2009 02:02:16 GMT</pubDate></item><item><title>zvolkov commented on Do you need a framework?</title><description>As always Ayende's specific recipe is wrong (don't copy/paste) but the thinking is useful.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment30</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment30</guid><pubDate>Thu, 06 Aug 2009 19:31:43 GMT</pubDate></item><item><title>Mikael Henriksson commented on Do you need a framework?</title><description>Great post great way of tackling unnecessary complexity that doesn't even need to be there! 
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment29</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment29</guid><pubDate>Thu, 06 Aug 2009 19:12:46 GMT</pubDate></item><item><title>Dmitry commented on Do you need a framework?</title><description>@Rafal,
  
  
You were probably missing CurrentSessionContext.Bind(Session); CurrentSessionContext.Unbind(SessionFactory); statements. You need the first statement after the session is opened and the second statement after the session is closed.
  
  
I like to use contextual session because I have a class managing NHibernate sessions in the data access assembly. This approach makes testing easier.
  
  
However, the new .NET System.Web.Abstractions assembly does let you mock HttpContext; but you would have to use HttpContextBase instead of HttpContext.
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment28</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment28</guid><pubDate>Thu, 06 Aug 2009 14:10:30 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Nathan,
  
Because this is a single use scenario, it is not generally applicable.
  
And NH does have builtin support for that.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment27</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment27</guid><pubDate>Thu, 06 Aug 2009 10:01:38 GMT</pubDate></item><item><title>Nathan commented on Do you need a framework?</title><description>Why doesn't NHibernate ship this in an assembly? I know when getting started with NHibernate just figuring out how to glue it into your application is little tricky.
  
  
If its so common you can copy and paste with impunity into every project, I dont see why NHibernate doesn't just give it to us as part of its distribution.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment26</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment26</guid><pubDate>Thu, 06 Aug 2009 09:35:58 GMT</pubDate></item><item><title>Rafal commented on Do you need a framework?</title><description>@Fabio - I've been asking just about this feature (contextual session through GetCurrentSession() ) on NHusers group few days ago but couldn't make it work in my setup. So I'm basically doing it manually, like Ayende. 
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment25</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment25</guid><pubDate>Thu, 06 Aug 2009 09:24:39 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Den,
  
I have a full article about it, which will be publish soon
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment24</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment24</guid><pubDate>Thu, 06 Aug 2009 08:13:52 GMT</pubDate></item><item><title>Tobin Harris commented on Do you need a framework?</title><description>@Fabio
  
  
Yeah, I use the CurrentSessionContext along with an enum, it's quick and simple:
  
  
UoW.Configure( conStr, UoW.Environment.Test );
  
  
[http://gist.github.com/108433](http://gist.github.com/108433)  
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment23</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment23</guid><pubDate>Thu, 06 Aug 2009 08:11:27 GMT</pubDate></item><item><title>Tobin Harris commented on Do you need a framework?</title><description>I also +1 this approach too. I actually got a bit further and have a code snippet on GitHub:
  
  
[http://gist.github.com/108433](http://gist.github.com/108433)  
  
I swipe this and modify on a per-project basis. I'd rather do that than worry about crafting and maintaining one complex DLL that works for all projects. 
  
  
  
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment22</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment22</guid><pubDate>Thu, 06 Aug 2009 08:09:21 GMT</pubDate></item><item><title>Fabio Maulo commented on Do you need a framework?</title><description>And not only that Oren.
  
For who what work with session-per-request + test and GetCurrentSessionContext the framework is NHibernate itself...
  
But believe me that it is really hard to explain.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment21</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment21</guid><pubDate>Thu, 06 Aug 2009 05:36:11 GMT</pubDate></item><item><title>Mike commented on Do you need a framework?</title><description>@Ayende
  
I +1 this post and its underlying premise. I abandoned a few  'common' libraries on my current project just because there was too much friction given the speed of development. 
  
I also bring in the unit tests for these snippets, if present since they take on a life of their own. You agree with doing this?
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment20</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment20</guid><pubDate>Thu, 06 Aug 2009 05:23:06 GMT</pubDate></item><item><title>Den commented on Do you need a framework?</title><description>Oren, what about session management in WindowsForms or WPF application? For example, the main form with grid and the dialog window to edit the current object with collections. 
  
If it is a one session conversation, then  how to load previous objects states, if the user was modify the data and press Cancel button?
  
If it is a two session process then  how to update main form persistent object, if the user was modify the data and pess Ok button?
  
  
P.S. Thank you for your open source mission.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment19</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment19</guid><pubDate>Thu, 06 Aug 2009 01:47:09 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Dmitry,
  
Because it would take me more time to write it up that way than this way, and because I have been doing it this way since before GetCurrentSession().
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment18</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment18</guid><pubDate>Thu, 06 Aug 2009 00:58:43 GMT</pubDate></item><item><title>Dmitry commented on Do you need a framework?</title><description>Oren, any reason why you are not using SessionFactory.GetCurrentSession() with current_session_context_class="web" instead of manually setting the HttpContext.Current.Item[""]?
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment17</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment17</guid><pubDate>Thu, 06 Aug 2009 00:53:09 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Nick,
  
The container injects that.
  
Setup is something like:
  
Container.Register(Component.For
&lt;isession()  
  
   .FactoryMethod(() =&gt; Global.CurrentSession)  
  
   .LifeStyle.Is(LifestyleType.Transient));  
  
&gt;</description><link>http://ayende.com/4101/do-you-need-a-framework#comment16</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment16</guid><pubDate>Wed, 05 Aug 2009 23:54:43 GMT</pubDate></item><item><title>Nick Aceves commented on Do you need a framework?</title><description>Oren,
  
  
How do you usually refer to your session in services, controllers, etc? Do you inject the current session using Windsor's factory method capability?
  
  
I'm guessing that you're NOT actually referencing "Global.CurrentSession" everywhere...
  
  
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment15</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment15</guid><pubDate>Wed, 05 Aug 2009 23:52:12 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Damien,
  
OpenSession is _very_ light, yes. It just create a new session, and the session create a few objects. It is all in memory, and no DB is involved at all.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment14</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment14</guid><pubDate>Wed, 05 Aug 2009 23:17:20 GMT</pubDate></item><item><title>Damien Guard commented on Do you need a framework?</title><description>Is SessionFactory.OpenSession() very lightweight because you call it on every request even if you have pages that don't need it.
  
  
I would have thought the lazy construction in CurrentSession get would have been a little safer.
  
  
[)amien
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment13</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment13</guid><pubDate>Wed, 05 Aug 2009 23:11:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Bunter,
  
No, I can't. Not and manage them.
  
The cost of managing the dependencies is just too high
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment12</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment12</guid><pubDate>Wed, 05 Aug 2009 22:49:48 GMT</pubDate></item><item><title>Bunter commented on Do you need a framework?</title><description>That's heresy! :)
  
But you _can_ have simple libs, you know.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment11</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment11</guid><pubDate>Wed, 05 Aug 2009 22:47:12 GMT</pubDate></item><item><title>Phil commented on Do you need a framework?</title><description>I typically let my IOC container take care of creating sessions for me.  I use StructureMap to cache the session factory as a singleton and then I have a session injected into the controller.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment10</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment10</guid><pubDate>Wed, 05 Aug 2009 22:09:34 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Igor,
  
Transactions are handled in a separate manner. Usually as part of the controller level, which orchestrate operations
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment9</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment9</guid><pubDate>Wed, 05 Aug 2009 21:55:23 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>DaRage,
  
You tend not to do things like that, just because the user doesn't do things like that.
  
But note that a session doesn't equate to a transaction.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment8</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment8</guid><pubDate>Wed, 05 Aug 2009 21:54:45 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you need a framework?</title><description>Nicolas,
  
Yes, it would.
  
Now I would need to manage configuration for it, I would need to carry on the DLL that contains it.
  
It is more of a mess than helping, just from dependency management perspective.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment7</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment7</guid><pubDate>Wed, 05 Aug 2009 21:54:02 GMT</pubDate></item><item><title>Igor T. commented on Do you need a framework?</title><description>Where/how are you calling the Flush()/Commit()/etc methods?
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment6</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment6</guid><pubDate>Wed, 05 Aug 2009 21:20:25 GMT</pubDate></item><item><title>Dmitry commented on Do you need a framework?</title><description>I agree with Nicolas. HttpModule's basically are reusable Global.asax.cs files and they do not interfere with application specific logic that might be in the Global.asax.cs.
</description><link>http://ayende.com/4101/do-you-need-a-framework#comment5</link><guid>http://ayende.com/4101/do-you-need-a-framework#comment5</guid><pubDate>Wed, 05 Aug 2009 21:18:25 GMT</pubDate></item></channel></rss>