本文整理汇总了C#中NHibernate.Cfg.Configuration.SessionFactoryName方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.SessionFactoryName方法的具体用法?C# Configuration.SessionFactoryName怎么用?C# Configuration.SessionFactoryName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.SessionFactoryName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureNHibernate
/// <summary>
/// Configure NHibernate
/// </summary>
private static Configuration ConfigureNHibernate()
{
Configuration configure = new Configuration();
configure.SessionFactoryName("SessionFactory");
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.Driver<SqlClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionStringName = RegtestingServerConfiguration.DefaultConnectionString;
//db.Timeout = 10;
//For testing
//db.LogFormattedSql = true;
//db.LogSqlInConsole = true;
//db.AutoCommentSql = true;
});
HbmMapping hbmMapping = GetMappings();
configure.AddDeserializedMapping(hbmMapping,"NHMapping");
SchemaMetadataUpdater.QuoteTableAndColumns(configure);
return configure;
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("Started publisher and inserting data.");
Publisher.Start();
var config = new Configuration();
config.Configure("nh.sqlserver.config");
config.SessionFactoryName("Test session factory");
config.AddAssembly(typeof(Dog).Assembly);
new SchemaUpdate(config).Execute(false, true);
using(var sessionFactory = config.BuildSessionFactory())
{
Stopwatch sw = new Stopwatch();
sw.Start();
InsertData(sessionFactory);
Console.WriteLine("Inserting data with logging took: {0}", sw.Elapsed);
sw.Restart();
Publisher.Shutdown();
Console.WriteLine("Publisher shutdown complete in {0}", sw.Elapsed);
Console.WriteLine("inserting data with publisher shutdown");
sw.Restart();
InsertData(sessionFactory);
Console.WriteLine("Inserting data without logging took: {0}", sw.Elapsed);
}
Console.ReadLine();
}
示例3: ConfigureNHibernate
static Configuration ConfigureNHibernate()
{
var configure = new Configuration();
configure.SessionFactoryName("HemArkivAccess");
configure.DataBaseIntegration(db =>
{
db.Dialect<NHibernate.JetDriver.JetDialect>();
db.Driver<NHibernate.JetDriver.JetDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.ConnectionStringName = "HemArkivAccess";
db.Timeout = 10;
// enabled for testing
db.LogFormattedSql = true;
db.LogSqlInConsole = false;
db.AutoCommentSql = false;
db.Timeout = 10;
//db.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();
});
var mapping = GetMappings();
configure.AddDeserializedMapping(mapping, "HemArkivAccess");
return configure;
}
示例4: BuildConfiguration
public Configuration BuildConfiguration(string connectionString, string sessionFactoryName)
{
Contract.Requires(!string.IsNullOrEmpty(connectionString), "ConnectionString is null or empty");
Contract.Requires(!string.IsNullOrEmpty(sessionFactoryName), "SessionFactory name is null or empty");
Contract.Requires(!string.IsNullOrEmpty(_databaseSchema), "Database Schema is null or empty");
Contract.Requires(_configurator != null, "Configurator is null");
return CatchExceptionHelper.TryCatchFunction(
() =>
{
DomainTypes = GetTypeOfEntities(_assemblies);
if (DomainTypes == null)
throw new Exception("Type of domains is null");
var configure = new Configuration();
configure.SessionFactoryName(sessionFactoryName);
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db => GetDatabaseIntegration(db, connectionString));
if (_configurator.GetAppSettingString("IsCreateNewDatabase").ConvertToBoolean())
{
configure.SetProperty("hbm2ddl.auto", "create-drop");
}
configure.Properties.Add("default_schema", _databaseSchema);
configure.AddDeserializedMapping(GetMapping(),
_configurator.GetAppSettingString("DocumentFileName"));
SchemaMetadataUpdater.QuoteTableAndColumns(configure);
return configure;
}, Logger);
}
示例5: 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();
}
示例6: ConfigureNHibernate
public static Configuration ConfigureNHibernate()
{
var configure = new Configuration();
configure.SessionFactoryName("Demo");
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.Driver<SqlClientDriver>();
db.ConnectionString = ConnectionString;
db.LogSqlInConsole = true;//用于显示输出SQL
});
return configure;
}
示例7: GetConfiguration
public static Configuration GetConfiguration()
{
var configure = new Configuration();
configure.SessionFactoryName("NHibernateDB");
//Proxy扩展方法用于配置NHibernate延迟加载的字节码提供程序
configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2005Dialect>();
db.Driver<SqlClientDriver>();
db.ConnectionString = _ConnectionString;
});
return configure;
}
示例8: BuildConfiguration
private static Configuration BuildConfiguration()
{
Configuration cfg = new Configuration();
cfg.SessionFactoryName("Sample.ReadModel");
cfg.DataBaseIntegration(db =>
{
db.Dialect<NHibernate.Dialect.MsSql2008Dialect>();
db.Driver<NHibernate.Driver.SqlClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ReadModel"].ConnectionString;
db.AutoCommentSql = true;
db.LogSqlInConsole = false;
db.LogFormatedSql = true;
db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
});
cfg.AddAssembly(typeof(NHibernateMappings).Assembly);
return cfg;
}
示例9: ConfigureNHibernate
public Configuration ConfigureNHibernate()
{
var configure = new Configuration();
configure.SessionFactoryName("Demo");
configure.Proxy(p =>
{
p.Validation = false;
p.ProxyFactoryFactory<ProxyFactoryFactory>();
});
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.Driver<SqlClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionString = ConnectionString;
db.Timeout = 10;
db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
});
return configure;
}
示例10: BuildConfiguration
public static Configuration BuildConfiguration(string connectionString)
{
var configure = new Configuration();
configure.SessionFactoryName("SessionFactoryName");
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2008Dialect>();
db.Driver<SqlClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionString = connectionString;
db.Timeout = 10;
db.LogFormattedSql = true;
db.LogSqlInConsole = true;
db.AutoCommentSql = true;
});
InitMappings(configure);
GenerateSchema(configure);
return configure;
}
示例11: ConfigureNhibernate
public static NHibernate.Cfg.Configuration ConfigureNhibernate()
{
var configure = new NHibernate.Cfg.Configuration();
configure.SessionFactoryName("BuildIt");
configure.DataBaseIntegration(db =>
{
//*** SQL 2012 Express
db.Dialect<MsSql2012Dialect>();
db.Driver<SqlClientDriver>();
db.ConnectionString = "Data Source=.\\sqlexpress2012;Initial Catalog=Dig;Integrated Security=True;Application Name=DigDb;";
//db.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["digdb"].ConnectionString;
db.Timeout = 10;
//*** Testing Settings
db.LogFormattedSql = true;
db.LogSqlInConsole = true;
db.AutoCommentSql = true;
});
return configure;
}
示例12: NHibernateConfigurationInBuild
public static void NHibernateConfigurationInBuild(TestContext context)
{
log4net.Config.XmlConfigurator.Configure();
Configuration cfg = new Configuration();
cfg.SessionFactoryName("BuildIt");
cfg.DataBaseIntegration(db =>
{
db.LogSqlInConsole = true;
db.ConnectionString = @"Server=localhost;initial catalog=nhibernate;User Id=sa;Password=masterkey;";
db.Driver<SqlClientDriver>();
db.Dialect<MsSql2012Dialect>();
});
var mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
cfg.AddAssembly(Assembly.GetExecutingAssembly());
SessionFactory = cfg.BuildSessionFactory();
}
示例13: initConfiguration
private Configuration initConfiguration()
{
var configure = new Configuration();
configure.SessionFactoryName("BuildIt");
configure.DataBaseIntegration(db =>
{
db.ConnectionProvider<DriverConnectionProvider>();
db.Dialect<MsSql2008Dialect>();
db.Driver<Sql2008ClientDriver>();
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = IsolationLevel.ReadCommitted;
db.ConnectionString = ConnectionString;
db.Timeout = 10;
db.BatchSize = 20;
if (ShowLogs)
{
db.LogFormattedSql = true;
db.LogSqlInConsole = true;
db.AutoCommentSql = false;
}
});
configure.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver,
typeof(ProfiledSql2008ClientDriver).AssemblyQualifiedName);
return configure;
}
示例14: InitializeNHibernate
// public class Order
// {
// public int Id { get; set; }
// public Customer Customer { get; set; }
// }
static void InitializeNHibernate()
{
NHibernateProfiler.Initialize();
cfg = new Configuration();
cfg.DataBaseIntegration(x =>
{
x.ConnectionStringName = "adventureworks";
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2008Dialect>();
x.IsolationLevel = IsolationLevel.ReadCommitted;
x.Timeout = 10;
});
cfg.SessionFactoryName("AdventureWorks");
cfg.Cache(x =>
{
x.Provider<HashtableCacheProvider>();
x.UseQueryCache = true;
});
cfg.SessionFactory().GenerateStatistics();
cfg.AddAssembly(typeof (Customer).Assembly);
}
示例15: ConfigureNHibernate
/// <summary>
/// Configuration nhibernate and data base
/// </summary>
/// <returns></returns>
private Configuration ConfigureNHibernate()
{
var configure = new Configuration();
configure.SessionFactoryName("SQL");
configure.DataBaseIntegration(db =>
{
db.Dialect<MsSql2012Dialect>();
db.Driver<NHibernate.Driver.SqlClientDriver>();
db.ConnectionString = this.ConnectionString.ConnectionString;
db.Timeout = 10;
db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
db.IsolationLevel = System.Data.IsolationLevel.ReadCommitted;
});
return configure;
}