本文整理汇总了C#中NHibernate.Tool.hbm2ddl.SchemaExport.Drop方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaExport.Drop方法的具体用法?C# SchemaExport.Drop怎么用?C# SchemaExport.Drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Tool.hbm2ddl.SchemaExport
的用法示例。
在下文中一共展示了SchemaExport.Drop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DatabaseRegistry
public DatabaseRegistry()
{
var nHibernateConfiguration = new EmployeeApplicationNHibernateConfiguration();
//string connectionString = ConfigurationManager.ConnectionStrings["EmployeeApplicationContext"].ConnectionString;
ISessionFactory sessionFactory = Fluently
.Configure()
.Database(SQLiteConfiguration.Standard.UsingFile(@"sqlite.db"))
//.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString))
.Mappings(m =>
m.AutoMappings
.Add(AutoMap.AssemblyOf<Employee>(nHibernateConfiguration))
)
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(true, true);
schemaExport.Create(true, true);
})
.BuildSessionFactory();
For<ISessionFactory>().Singleton().Use(sessionFactory);
For<ISession>().HybridHttpOrThreadLocalScoped().Use(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());
//TODO: Handle Tansactions For Application
//For<IUnitOfWork>().CacheBy(new HybridLifecycle()).Use<UnitOfWork>();
}
示例2: Main
static void Main(string[] args)
{
//var assemblyNames = ConfigurationManager.AppSettings["nhibernate.assemblies"];
//if (assemblyNames.IsNullOrEmpty())
// throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");
//var config = new NHibernate.Cfg.Configuration();
//config.Configure();
//foreach (MappingAssembly assembly in TitanConfiguration.Instance.MappingAssemblies)
// config.AddAssembly(assembly.Name);
TitanFramework.Data.NHib.NHibernateHelper.InitialIze();
var config = TitanFramework.Data.NHib.NHibernateHelper.Configuration;
var rebuildDatabase = ConfigurationManager.AppSettings["nhibernate.rebuilddatabase"];
if (TitanFramework.Extensions.StringExtensions.IsNullOrEmpty(rebuildDatabase))
throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");
switch (rebuildDatabase.ToLower())
{
case "rebuild":
var schemaExport = new SchemaExport(config);
schemaExport.Drop(false, true);
schemaExport.Execute(true, false, false);
break;
case "update":
var schemaUpdate = new SchemaUpdate(config);
schemaUpdate.Execute(true, true);
break;
}
}
示例3: First_we_need_a_schema_to_test
public void First_we_need_a_schema_to_test()
{
var schemaExport = new SchemaExport(_cfg);
schemaExport.Drop(true, true);
schemaExport.Create(true, true);
try
{
using (IUnitOfWork work = UnitOfWork.Start())
using (ITransaction transaction = work.BeginTransaction(IsolationLevel.Serializable))
{
using (var repository = new NHibernateRepository())
{
repository.Save(new TestSaga(_sagaId) { Name = "Joe" });
repository.Save(new TestSaga(CombGuid.Generate()) { Name = "Chris" });
work.Flush();
transaction.Commit();
}
}
}
finally
{
UnitOfWork.Finish();
}
}
示例4: BuildSchema
private void BuildSchema(Configuration cfg)
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(script: false, export: true);
schemaExport.Create(script: false, export: true);
}
示例5: NHibernateRegistry
public NHibernateRegistry()
{
Configuration cfg = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.UsingFile("database.db"))
.Mappings(m => m.AutoMappings
.Add(AutoMap
.AssemblyOf<ProductDetailViewModel>()
.Conventions
.Add(new ClassConvention())))
.BuildConfiguration();
cfg.SetProperty(Environment.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName);
cfg.SetProperty(Environment.ConnectionDriver, typeof (SQLite20Driver).AssemblyQualifiedName);
var export = new SchemaExport(cfg);
export.Drop(true,true);
export.Create(true,true);
ISessionFactory sessionFactory = cfg.BuildSessionFactory();
ForRequestedType<Configuration>().AsSingletons()
.TheDefault.IsThis(cfg);
ForRequestedType<ISessionFactory>().AsSingletons()
.TheDefault.IsThis(sessionFactory);
ForRequestedType<ISession>().CacheBy(InstanceScope.Hybrid)
.TheDefault.Is.ConstructedBy(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());
ForRequestedType<IUnitOfWork>().CacheBy(InstanceScope.Hybrid)
.TheDefaultIsConcreteType<UnitOfWork>();
ForRequestedType<IDatabaseBuilder>()
.TheDefaultIsConcreteType<DatabaseBuilder>();
}
示例6: BuildSchema
private void BuildSchema(Configuration config)
{
SchemaExport schema = new SchemaExport(config);
schema.Drop(this._criaScript, this._exportaScriptBD);
schema.Create(this._criaScript, this._exportaScriptBD);
config.SetInterceptor(new SqlStatementInterceptor());
}
示例7: BuildDatabase
private static void BuildDatabase(ISessionBuilder builder)
{
Configuration config = builder.GetConfiguration();
var export = new SchemaExport(config);
export.Drop(false, false);
export.Create(true, true);
}
示例8: CreateDb
public static void CreateDb()
{
var config = new Configuration().Configure(GetPath() + "\\nhibernate.cfg.xml");
var schemaExport = new SchemaExport(config);
schemaExport.Drop(true, false);
schemaExport.Create(true, true);
}
示例9: HelloWorldStructureMapRegistry
public HelloWorldStructureMapRegistry()
{
IncludeRegistry<ProAceCoreRegistry>();
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("HelloWorld")).ShowSql())
.Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<MapMarker>();
m.FluentMappings.Conventions.AddFromAssemblyOf<CollectionAccessConvention>();
})
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Drop(true, true);
schemaExport.Create(true, true);
For<NHibernate.Cfg.Configuration>().Use(cfg);
})
.BuildSessionFactory();
For<ISessionFactory>()
.Singleton()
.Use(sessionFactory);
For<ISession>()
.Use(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());
For<IUserRepository>().Use<UserRepository>();
}
示例10: Application_Start
protected void Application_Start()
{
new Configurator().StartServer<Configurator>();
var cfg = Simply.Do.GetNHibernateConfig();
var check = new SchemaValidator(cfg);
try
{
check.Validate();
}
catch
{
var exp = new SchemaExport(Simply.Do.GetNHibernateConfig());
exp.Drop(true, true);
exp.Create(true, true);
using (Simply.Do.EnterContext())
{
UserSample.Init();
GroupSample.Init();
}
}
RegisterRoutes(RouteTable.Routes);
}
示例11: BuildTestSessionFactory
private static ISessionFactory BuildTestSessionFactory() {
var testDatabaseConnectionString = "LocalDB";
var config = DatabaseConfiguration.Configure(testDatabaseConnectionString);
/*
* Need to comment these out when not needed because session factory can only be created once.
* Database schemas need to be created BEFORE NHibernate schema export.
* This needs to be run only once.
*/
/*
var fac = DatabaseConfiguration.BuildSessionFactory(config);
CreateSchemas(fac);*/
// Drop old database if any, create new schema
config.ExposeConfiguration(cfg => {
var export = new SchemaExport(cfg);
//export.SetOutputFile(@"C:\Temp\vdb.sql");
export.Drop(false, true);
export.Create(false, true);
});
var fac = DatabaseConfiguration.BuildSessionFactory(config);
FinishDatabaseConfig(fac);
return fac;
}
示例12: FluentlyConfigureSqlite
protected virtual Configuration FluentlyConfigureSqlite(SqliteDatabase database) {
var filePath = database.FilePath;
SQLiteConfiguration liteConfiguration =
SQLiteConfiguration.Standard
.UsingFile(filePath)
.ProxyFactoryFactory(typeof(ProxyFactoryFactory));
var fluentConfig =
Fluently
.Configure()
.Database(liteConfiguration)
.Mappings(m => m.FluentMappings.AddFromAssembly(GetType().Assembly))
// Install the database if it doesn't exist
.ExposeConfiguration(config =>
{
if (File.Exists(filePath)) return;
SchemaExport export = new SchemaExport(config);
export.Drop(false, true);
export.Create(false, true);
})
.BuildConfiguration();
AddProperties(fluentConfig);
return fluentConfig;
}
示例13: CreateSchema
public void CreateSchema(bool outputToConsole)
{
if (config == null)
throw new Exception("You must CreateSessionFactory before attempting to CreateSchema.");
var export = new SchemaExport(config);
export.Drop(outputToConsole, true);
export.Create(outputToConsole, true);
}
示例14: DropSchemas
public void DropSchemas(bool script, bool export)
{
foreach (PersistenceUnit pu in PersistenceUnitRepo.Instance.PersistenceUnits)
{
SchemaExport se = new SchemaExport(pu.NHConfiguration);
se.Drop(script, export);
}
}
示例15: DropDatabase
public void DropDatabase()
{
Setup();
var session = _configuration.BuildSessionFactory().OpenSession();
var export = new SchemaExport(_configuration);
export.Execute(true, false, true, session.Connection, null);
export.Drop(false, true);
}