36 lines
990 B
C#
36 lines
990 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using NHibernate;
|
|
using NHibernate.Cfg;
|
|
|
|
namespace GeneralApi.Core.Infrastructure.DataAccess
|
|
{
|
|
public class SessionSource : ISessionSource
|
|
{
|
|
// public static Func<Type, object> CreateDependencyCallback = (type) => Activator.CreateInstance(type);
|
|
//
|
|
// private T CreateDependency<T>()
|
|
// {
|
|
// return (T)CreateDependencyCallback(typeof(T));
|
|
// }
|
|
|
|
private readonly ISessionFactory _sessionFactory;
|
|
|
|
public SessionSource(Configuration configuration)
|
|
{
|
|
_sessionFactory = configuration.BuildSessionFactory();
|
|
}
|
|
|
|
public ISession CreateSession()
|
|
{
|
|
//var interceptor = CreateDependency<ChangeAuditInfoInterceptor>();
|
|
|
|
ISession session = _sessionFactory.OpenSession(/*interceptor*/);
|
|
session.FlushMode = FlushMode.Commit;
|
|
return session;
|
|
}
|
|
}
|
|
}
|