static void SetDefaultConfig(FluentConfiguration config) { config.Mappings(c => { c.FluentMappings.Conventions.AddFromAssemblyOf <EnumConvention>(); var hbmXmlPath = Path.Combine(PathHelper.AppDataPath, "hbmXml"); DirectoryHelper.CreateIfNotExists(hbmXmlPath); c.FluentMappings.AddFromAssembly(_entityMapAssembly).ExportTo(hbmXmlPath); c.FluentMappings.Conventions.Add(DefaultLazy.Never()); c.FluentMappings.Conventions.Add( ConventionBuilder.HasMany.Always(x => { x.Fetch.Join(); }), ConventionBuilder.HasManyToMany.Always(x => { x.Fetch.Join(); }), ConventionBuilder.Reference.Always(x => { x.ReadOnly(); x.Fetch.Join(); x.Nullable(); x.NotFound.Ignore(); })); }); config.Cache(x => x.ProviderClass <NoCacheProvider>()); }
public static ISessionFactory GetSessionFactory() { if (null == _sessionFactory) { FluentConfiguration nhConfig = Fluently.Configure() .Database( MsSqlConfiguration.MsSql2008.ConnectionString( c => c.Database(_conn.InitialCatalog).Server(_conn.DataSource).TrustedConnection())) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <Itens>() .Conventions.Add(DefaultLazy.Never())); nhConfig.Cache(c => c.ProviderClass <SysCacheProvider>().UseSecondLevelCache()); _sessionFactory = nhConfig.ExposeConfiguration(v => new SchemaExport(v).Create(false, false)).BuildSessionFactory(); } return(_sessionFactory); }
private static ISessionFactory CreateSessionFactory() { MsSqlCeConfiguration sqlconfig = MsSqlCeConfiguration.Standard. Dialect <MsSql2000Dialect>().ConnectionString(ConnectionString); FluentConfiguration fc = Fluently.Configure(); fc = fc.Database(sqlconfig); ISessionFactory sessionFactory = fc.Cache(c => c .UseQueryCache() .ProviderClass <HashtableCacheProvider>()) .Mappings(m => m .FluentMappings.AddFromAssemblyOf <PlayerMap>()) .ExposeConfiguration((NHibernate.Cfg.Configuration config) => new SchemaUpdate(config) .Execute(false, true)) .BuildConfiguration() .BuildSessionFactory(); return(sessionFactory); }