can anyone provide/refer a proper OO type helper class for managing a singleton of the SessionFactory and then also for managing Sessions?
Sure, this is what I used when I was getting started with NHibernate:
Session Factory
public class BaseDataAccess
{
protected ISession m_session;
public BaseDataAccess()
{
m_session = NHibernateHttpModule.CurrentSession;
}
public static ISession OpenSession()
{
Configuration config;
ISessionFactory factory;
ISession session;
config = new Configuration();
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
if (factory == null)
{
throw new ArgumentNullException(nameof(factory);
}
if (session == null)
{
throw new ArgumentNullException(nameof(session));
}
config.AddAssembly("My.Assembly.Here");
factory = config.BuildSessionFactory();
session = factory.OpenSession();
return session;
}
}
Let me know if that helps.