本文整理汇总了C#中NHibernate.Cfg.Configuration.CurrentSessionContext方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.CurrentSessionContext方法的具体用法?C# Configuration.CurrentSessionContext怎么用?C# Configuration.CurrentSessionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.CurrentSessionContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSessionFactory
/// <summary>
/// Creates session factory
/// </summary>
/// <param name="configurationReader">configuration reader</param>
/// <returns></returns>
private static ISessionFactory CreateSessionFactory(IConfigurationReader configurationReader)
{
var configuration = new NHibernate.Cfg.Configuration();
configuration.SessionFactoryName("Jumblocks Blog");
configuration.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008FixedDialect>();
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionString = configurationReader.ConnectionStrings["BlogDb"].ConnectionString;
db.BatchSize = 100;
//for testing
db.LogFormattedSql = true;
db.LogSqlInConsole = true;
db.AutoCommentSql = true;
});
var mapper = new ModelMapper();
mapper.AddMapping<BlogPostMap>();
mapper.AddMapping<BlogUserMap>();
mapper.AddMapping<ImageReferenceMap>();
mapper.AddMapping<TagMap>();
mapper.AddMapping<SeriesMap>();
mapper.AddMapping<UserMap>();
mapper.AddMapping<RoleMap>();
mapper.AddMapping<OperationMap>();
configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
configuration.CurrentSessionContext<WebSessionContext>();
return configuration.BuildSessionFactory();
}
示例2: Apply
public virtual void Apply(Configuration configuration, IDatabaseProvider databaseProvider)
{
configuration.CurrentSessionContext<CallSessionContext>();
configuration.DataBaseIntegration(db => SetDatabase(db, databaseProvider, configuration));
configuration.Cache(SetCache);
configuration.Proxy(SetProxy);
}
示例3: Initialize
public static void Initialize()
{
if (SessionFactoryHolder.DefaultSessionFactory != null) { return; }
var cfg = new Configuration();
cfg.CurrentSessionContext<WcfOperationSessionContext>()
.DataBaseIntegration(ForSQLiteInMemory)
.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
.SessionFactory()
.GenerateStatistics();
SessionFactoryHolder.DefaultSessionFactory = cfg.BuildSessionFactory();
}
示例4: GetNHibernateSessionFactory
public static ISessionFactory GetNHibernateSessionFactory()
{
var configure = new NHibernate.Cfg.Configuration();
configure.DataBaseIntegration(delegate(NHibernate.Cfg.Loquacious.IDbIntegrationConfigurationProperties dbi) {
dbi.ConnectionStringName = "mvcWithNHibernate";
dbi.Dialect<NHibernate.Dialect.MySQLDialect>();
dbi.Driver<NHibernate.Driver.MySqlDataDriver>();
dbi.Timeout = 255;
});
configure.CurrentSessionContext<NHibernate.Context.WebSessionContext>();
//configure.AddAssembly(typeof(NHibernateMappings.User).Assembly);
configure.AddAssembly(typeof(NHibernateMappings.Shop).Assembly);
return configure.BuildSessionFactory();
}
示例5: CreateSessionFactory
private void CreateSessionFactory(string assemblyName, string connStr)
{
Configuration cfg = new Configuration();
cfg.CurrentSessionContext<ThreadStaticSessionContext>();
cfg.DataBaseIntegration(o =>
{
o.ConnectionProvider<DriverConnectionProvider>();
o.Dialect<SQLiteDialect>();
o.Driver<SQLite20Driver>();
o.ConnectionString = connStr;
o.BatchSize = 100;
});
cfg.AddAssembly(assemblyName);
SessionFactory = cfg.BuildSessionFactory();
SchemaExport = new SchemaExport(cfg);
SchemaExport.Create(false, true);
}
示例6: Start
/// <summary>
/// Starts this instance.
/// </summary>
public static void Start()
{
var configuration = new Configuration();
configuration.DataBaseIntegration(db =>
{
db.Dialect<MsSql2012Dialect>();
db.Driver<SqlClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.SchemaAction = SchemaAutoAction.Validate;
db.ConnectionStringName = ConnectionStringName;
});
configuration.CurrentSessionContext<WebSessionContext>();
var factory = Fluently.Configure(configuration)
.Mappings(m => m.FluentMappings.AddFromAssembly(typeof(TodoMap).Assembly))
.ExposeConfiguration(cfg => new SchemaExport(cfg).Execute(false, true, false))
.BuildSessionFactory();
SessionSource.SetFactory(factory);
}
示例7: GetNHibernateSessionFactory
public static ISessionFactory GetNHibernateSessionFactory(string connStringKeyName)
{
if (string.IsNullOrEmpty(connStringKeyName))
throw new ArgumentNullException("connStringKeyName");
var configs = new NHibernate.Cfg.Configuration();
configs.DataBaseIntegration(i =>
{
i.Dialect<NHibernate.Dialect.MsSql2012Dialect>();
i.Driver<NHibernate.Driver.Sql2008ClientDriver>();
i.ConnectionStringName = connStringKeyName;
i.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();
});
configs.CurrentSessionContext<NHibernate.Context.WebSessionContext>();
// assembly of poco classes
configs.AddAssembly(typeof(NHibernateMVCApp.Repository.Mappings.Product).Assembly);
return configs.BuildSessionFactory();
}
示例8: Initialize
public static Configuration Initialize()
{
ModelMapper mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetAssembly(typeof(NHibernateSessionManager)).GetExportedTypes());
Configuration cfg = new Configuration();
cfg.DataBaseIntegration(c =>
{
c.Driver<SqlServerCeDriver>();
c.Dialect<MsSqlCe40Dialect>();
c.LogSqlInConsole = true;
c.LogFormattedSql = true;
c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
c.ConnectionString = ConnectionString;
});
cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
cfg.CurrentSessionContext<ThreadStaticSessionContext>();
// Set up second level caching
cfg.Cache(props =>
{
props.Provider<AppFabricProvider>();
props.UseQueryCache = true;
});
// (Re-)create the database.
new SchemaExport(cfg).Execute(false, true, false);
_sessionFactory = cfg.BuildSessionFactory();
return cfg;
}
示例9: Configure
public static void Configure()
{
NHConguration = new Configuration().Configure();
NHConguration.CurrentSessionContext<WcfOperationSessionContext>();
NHConguration.LinqToHqlGeneratorsRegistry<NHibernateLinqToHqlGeneratorsRegistry>();
sessionFactory = NHConguration.BuildSessionFactory();
}
示例10: ExposeConfiguration
protected override void ExposeConfiguration(Configuration cfg)
{
base.ExposeConfiguration(cfg);
cfg.CurrentSessionContext<NHibernate.Context.WebSessionContext>();
}