May also want to check into using something like s#arp
architecture<http://code.google.com/p/sharp-architecture/> ,
which I believe manages much of that for you.

On Thu, Jun 18, 2009 at 7:31 AM, Ben Hyrman <[email protected]> wrote:

>
> What's your context? Web app or Win app? Using an IoC container?
>
> Just my two pence, here's what I've started doing (not sure if it's
> the best, but it's been working <grin>).
>
>            ISessionFactory factory = fluentConfig.BuildSessionFactory();
>
>
>  ForRequestedType<ISessionFactory>().CacheBy(InstanceScope.Singleton)
>                .TheDefault.IsThis(factory);
>
>            ForRequestedType<ISession>().CacheBy(InstanceScope.Hybrid)
>                .TheDefault.Is.ConstructedBy(c =>
> c.GetInstance<ISessionFactory>().OpenSession());
>
> For Web apps, I prefer to stuff the ISession in the http items.
> Creating a session is cheap and it'll only connect to the DB when it
> needs to. So, creating a bunch and just throwing them away is fine.
>
> For a Win app, think about doing things in a conversational manner.
> Think about things in the scope of a business transaction. Open your
> session at the start of that business transaction and then commit and
> flush at the end.
>
> Ben
>
>
> On Tue, Jun 16, 2009 at 9:45 PM, DjSinae<[email protected]> wrote:
> >
> > Hi i'm sure this is a common question but i just want to be sure of my
> > options here.
> >
> > Where should i put the SessionFactory object?
> >
> > Should i make it a singleton?? a static object
> >
> > Should i put in the the basemodel class (as static object)
> >
> > Should i put it in the App.cs class as singleton and access it using
> > the Application.Current to access it??
> >
> > Any better idea?
> >
> > thx for helping
> >
> > Also, when should i create / close a session?? Every time i make a
> > transaction??
> >
> > >
> >
>
> >
>


-- 
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to