Session creation is (according to my reading) a very lightweight
process, so you probably should do what is safest or easiest, without
worrying about performance.

Can't offer advice on your other questions...sorry.

-Tom Bushell

On Feb 1, 4:57 pm, Berryl Hesh <[email protected]> wrote:
> I would like to have a base class for working with a sqlite session in
> an app that has both desktop and web support, as well as two databases
> (one green and one legacy).
>
> My thinking is that this will lead to one well tested place to go for
> session lifecycle and reduce the clutter from the management of the
> persistence model. At some point though I would want to provide the
> same services for the actual database, and I don't want to wind up
> writing my own FNH! If some of you have gone down this road and
> decided it's easier to just configure FNH several times for several
> variations please let me know.
>
> Below is my current code, which I have a few questions about:
> 1) can I get a IStatelessSession from a SessionSource?
> 2) is SessionSource the best way to get an ISession when you need it?
> 3) when making a sql test fixture that involves state changes and
> several test cases, is there a perf advantage availble by
> instantiating the whole session once in the fixture setup, or is it
> safer to just blow away the whole session and recreate it for every
> test? (more an NHib question than FNH, I know)
>
> Thanks,
> Berryl
>
> == CODE ============
>
> public class InMemoryDbSessionProvider : IDisposable
>     {
>         public ISession Session { get; private set; }
>         public IStatelessSession Session { get; private set; } //
> where does this come from?
>         public Configuration Cfg { get; private set; }
>         public SessionSource SessionSource { get; set; }
>
>         public InMemoryDesktopDbSessionProvider(PersistenceModel
> persistenceModel)
>         {
>             var SQLiteCfg = SQLiteConfiguration.Standard.InMemory
> ().ShowSql();
>             SQLiteCfg.ProxyFactoryFactory(typeof
> (ProxyFactoryFactory).AssemblyQualifiedName);
>
>             var fluentCfg = Fluently.Configure().Database
> (SQLiteCfg).ExposeConfiguration(cfg => { Cfg = cfg; });
>             SessionSource = new SessionSource
> (fluentCfg.BuildConfiguration().Properties, persistenceModel);
>             Session = SessionSource.CreateSession();
>         }
>
>         public void Dispose() {
>             Session.Close();
>             Session.Dispose();
>             Session = null;
>           }
>     }

-- 
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