Moved to fluent. Added support for Modifiers. Fixtures to load intial test data
This commit is contained in:
1 parent
c841dc25f4
commit
eb48c3754a
272 files changed
+10470
-47160
No files matched your search
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FluentNHibernate.Automapping;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using Tanshu.Accounts.Conventions;
|
||||
using Tanshu.Accounts.Entities;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using FluentNHibernate.Conventions.Helpers;
|
||||
|
||||
namespace Tanshu.Accounts.SqlDAO
|
||||
{
|
||||
public sealed class SessionManager
|
||||
{
|
||||
private readonly Configuration cfg;
|
||||
private readonly ISessionFactory factory;
|
||||
private SessionManager()
|
||||
{
|
||||
cfg = GetConfiguration();
|
||||
factory = cfg.BuildSessionFactory();
|
||||
}
|
||||
|
||||
//public static SessionManager Instance
|
||||
//{
|
||||
// get { return Nested.sessionManager; }
|
||||
//}
|
||||
public static ISession Session
|
||||
{
|
||||
get { return Nested.sessionManager.GetSession(); }
|
||||
}
|
||||
public static Configuration Configuration
|
||||
{
|
||||
get { return Nested.sessionManager.GetConfiguration(); }
|
||||
}
|
||||
private class Nested
|
||||
{
|
||||
static Nested() { }
|
||||
internal static readonly SessionManager sessionManager = new SessionManager();
|
||||
}
|
||||
|
||||
public Configuration GetConfiguration()
|
||||
{
|
||||
var storeConfiguration = new StoreConfiguration();
|
||||
var persistenceModel = AutoMap.AssemblyOf<Voucher>(storeConfiguration)
|
||||
.Conventions.Setup(c =>
|
||||
{
|
||||
c.Add<PrimaryKeyConvention>();
|
||||
c.Add<CustomForeignKeyConvention>();
|
||||
c.Add<ClassConvention>();
|
||||
c.Add(DefaultLazy.Never());
|
||||
//c.Add<EnumConvention>();
|
||||
});
|
||||
|
||||
return Fluently.Configure()
|
||||
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(p => p.FromConnectionStringWithKey("FluentCon")))
|
||||
.Mappings(m => m.AutoMappings.Add(persistenceModel))
|
||||
.BuildConfiguration()
|
||||
.SetInterceptor(new NHSQLInterceptor());
|
||||
}
|
||||
public ISession GetSession()
|
||||
{
|
||||
return factory.OpenSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user