Welcome Guest, you are in: Login

Castle Project


Navigation (Windsor)

Search the wiki


This documentation is a work in progress.

Let us know if some information is not clear, inaccurate or missing. Also feel free to update the wiki yourself.

Windsor Tutorial - Part Six - Persistence Layer

Page discussion for Windsor Tutorial - Part Six - Persistence Layer
ISession "lifestyle PerWebRequest"2010/12/30 16:32 by José F. Romaniello
I am not sure about managing the isession lifestyle with the container, what happens when you inject isession on a singleton service like a repository? Or are you going to use another artifact with lifestyle = PerWebRequest, lets say a ISessionProvider or something like that which act as a typed factory?
Re: ISession "lifestyle PerWebRequest"2010/12/30 23:37 by Krzysztof Koźmic
Thanks for your comment Jose.

The general rule is to not take dependency on an object that is supposed to live shorter than you. So singleton depending on a per-web-request object is in 99% of cases a bug. If we have a legitimate case when we want to do it than yes - we'd have to go through a layer of indirection, which means a factory most likely.

Notice also that this is a introductory tutorial and I want to take it in very small steps not to overwhelm the reader by dumping lots of new information on them in every part of the tutorial. That's why I try to keep them small and each explaining just one step of the process.

Feel free to contribute, and add a part discussing some aspect of Windsor, in conjunction with scenario where you'd have a singleton depending on pwr object and demonstrate another session management mechanism.

Trouble accessing the DB2011/08/07 18:44 by Henway
The tutorial has been great up to this point. However, I think I have an NHibernate problem that I can't figure out...

I have a connectionstring of

    <add name="ApplicationServices"
         connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ToBeSeenDB;Integrated Security=True"
         providerName="System.Data.SqlClient" />

I know the connection string is OK, because I can connect to the ToBeSeenDB database via the Database Explorer.

However, inside the HomeController.cs, the following line always returns zero (0), when I know there is one row in the Event table:

  ViewBag.EventCount = session.QueryOver<Event>().RowCount();

I can't seem to diagnose why I am getting nothing back. I'm not sure this is a Windsor problem or an NHibernate problem. I should reiterate, that I have been following this tutorial one step at a time, so I haven't just downloaded all the code from github. However, All the essential parts are there and the MVC app works and generates a response for the browser; I simply get a rowcount of zero!

I would really appreciate any help and I have been trying to diagnose this problem!
using entity framework 5 (database first)2013/02/14 17:03 by misuk11
are there any examples available that use entity framework and its dbcontext instead of NHibernate ? Im new to DI and am trying to follow the mvc3 tutorial but it uses nhibernate and Im using entity framework. Im completely stuck here and dont know how to proceed, can anyone provide some examples ?

ScrewTurn Wiki version Some of the icons created by FamFamFam.