本文整理汇总了C#中NHibernate.Tool.hbm2ddl.SchemaUpdate.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaUpdate.Execute方法的具体用法?C# SchemaUpdate.Execute怎么用?C# SchemaUpdate.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Tool.hbm2ddl.SchemaUpdate
的用法示例。
在下文中一共展示了SchemaUpdate.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize(TestContext context)
{
var cfg = new Configuration();
cfg.DataBaseIntegration(x => {
x.ConnectionString = "Server=localhost;Database=test;Uid=root;Pwd=kmn23po;";
x.Driver<MySqlDataDriver>();
x.Dialect<MySQLDialect>();
x.LogSqlInConsole = true;
x.BatchSize = 30;
});
var mapper = new ModelMapper();
mapper.AddMapping<ParentMap>();
mapper.AddMapping<ParentWithGuidMap>();
mapper.AddMapping<ChildMap>();
cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
sessionFactory = cfg.BuildSessionFactory();
var schemaUpdate = new SchemaUpdate(cfg);
schemaUpdate.Execute(false, true);
InsertData();
}
示例2: UpdateExistingDatabase
public void UpdateExistingDatabase(SchemaDefinition definition)
{
CheckDefinitionIsValid(definition);
var schemaUpdate = new SchemaUpdate(definition.Configuration);
if (definition.FileDefinition != null && !string.IsNullOrWhiteSpace(definition.FileDefinition.FileName))
{
//output the sql to create the db to a file.
string filename = Path.Combine(string.IsNullOrWhiteSpace(definition.FileDefinition.OutputFolder) ? "" : definition.FileDefinition.OutputFolder, definition.FileDefinition.FileName);
Action<string> updateExport = x =>
{
using (var file = new FileStream(filename, FileMode.Append, FileAccess.Write))
using (var sw = new StreamWriter(file))
{
sw.Write(x);
sw.Close();
}
};
schemaUpdate.Execute(updateExport, true);
}
else
{
schemaUpdate.Execute(false, true);
}
}
示例3: TryAlterDbSchema
public void TryAlterDbSchema()
{
var config = ServiceLocator.Current.GetInstance<NHibernate.Cfg.Configuration>();
var schemaUpdate = new SchemaUpdate(config);
schemaUpdate.Execute(true, true);
}
示例4: Init
protected override void Init()
{
var config = ConfigureNHibernate();
var schemaExport = new SchemaUpdate(config);
schemaExport.Execute(false, true);
//var schemaCreator = new SchemaExport(config);
//schemaCreator.Drop(false, true);
//schemaCreator.Create(false, true);
Kernel.Register(
Component.For<ISessionFactory>().LifeStyle.Singleton
.UsingFactoryMethod(config.BuildSessionFactory));
Kernel.Register(Component.For<ISession>().Named("PerThreadSession")
.LifeStyle
.PerThread
.UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
.OnCreate((kernel, session) => { session.FlushMode = FlushMode.Commit; }));
Kernel.Register(Component.For<ISession>().Named("PerWebRequestSession")
.LifeStyle
.PerWebRequest
.UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
.OnCreate((kernel, session) => { session.FlushMode = FlushMode.Commit; }));
}
示例5: BaseTest
public BaseTest()
{
_configuration = SessionFactory.GetConfiguration();
SchemaUpdate su = new SchemaUpdate(_configuration);
//se.Execute(false, false, true);
su.Execute(true, true);
}
示例6: 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;
}
}
示例7: CreateSchema
private static void CreateSchema(Configuration cfg)
{
var schemaExport = new SchemaUpdate(cfg);
schemaExport.Execute(true, true);
}
示例8: OnFixtureSetup
protected override void OnFixtureSetup()
{
Configuration configuration = Fluently.Configure()
.Database(SQLiteConfiguration.Standard
.ConnectionString(connstr =>
connstr.Is("Data Source=:memory:;Version=3;New=True;"))
.Dialect<SQLiteDialect>()
.Driver<SQLite20Driver>()
.Provider<TestConnectionProvider>()
.ShowSql())
.CurrentSessionContext("thread_static")
.ProxyFactoryFactory<ProxyFactoryFactory>()
.Mappings(m =>
m.AutoMappings
.Add(
AutoMap.Assembly(
Assembly.Load("Blog.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"))
.Where(c => c.BaseType == typeof (Entity) || c.BaseType == typeof (StampedEntity))
.Conventions
.Add<CustomCollectionConvetion>()
.Conventions
.Add<CascadeAll>()
.Conventions.Add<HiLoIndetityStrategy>()
.Conventions.Add<TableNamePluralizeConvention>()
.Conventions.Add<CustomForeignKeyConvention>()))
.ExposeConfiguration(ConfigValidator)
.BuildConfiguration();
var schema = new SchemaUpdate(configuration);
schema.Execute(true, true);
SessionFactory = configuration.BuildSessionFactory();
}
示例9: Main
static void Main(string[] args)
{
List<SongInfo> songProperties = FileReader.GetProperties("music.txt");
FluentConfiguration config = Fluently
.Configure()
.Database(MsSqlConfiguration
.MsSql2008
.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=Songs;Integrated Security=True;Pooling=False"))
.Mappings(configuration => configuration
.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
;
var export = new SchemaUpdate(config.BuildConfiguration());
export.Execute(true, true);
ISessionFactory sessionFactory = config.BuildSessionFactory();
using (ISession session = sessionFactory.OpenSession())
{
var tracks = session.QueryOver<ArtistInfo>().List();
foreach (var track in tracks)
{
Console.WriteLine(track);
Console.WriteLine("=====");
}
}
}
示例10: BuildSchema
private static void BuildSchema(Configuration config)
{
// This NHibernate tool takes a configuration (with mapping info in)
// and exports a database schema from it.
var dbSchemaExport = new SchemaUpdate(config);
//dbSchemaExport.Drop(false, true);
dbSchemaExport.Execute(false, true);
}
示例11: UpdateSchema
public static void UpdateSchema(string ConnString)
{
FNHMVC.Data.Infrastructure.ConnectionHelper.GetConfiguration(ConnString).ExposeConfiguration(cfg =>
{
var schemaUpdate = new NHibernate.Tool.hbm2ddl.SchemaUpdate(cfg);
schemaUpdate.Execute(false, true);
}).BuildConfiguration();
}
示例12: Update_an_existing_database_schema
public void Update_an_existing_database_schema()
{
_cfg = new Configuration();
_cfg.Configure();
_cfg.AddAssembly(Assembly.LoadFrom("DataLayer.dll"));
var update = new SchemaUpdate(_cfg);
update.Execute(true, false);
}
示例13: TreatConfiguration
private static void TreatConfiguration(NHibernate.Cfg.Configuration configuration)
{
var update = new SchemaUpdate(configuration);
update.Execute(false, true);
// configuration.SetProperty("current_session_context_class", "web");
}
示例14: BuildSchema
/// <summary>
/// Creates/Updates the database schema.
/// </summary>
private void BuildSchema()
{
// Build the schema.
var schemaUpdate = new SchemaUpdate(_configuration);
// Create/Update the schema.
schemaUpdate.Execute(false, true);
}
示例15: SchemaUpdateAddsIndexesThatWerentPresentYet
public void SchemaUpdateAddsIndexesThatWerentPresentYet()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", GetType().Assembly);
var su = new SchemaUpdate(cfg);
var sb = new StringBuilder(500);
su.Execute(x => sb.AppendLine(x), false);
Assert.That(sb.ToString(), Is.StringContaining("create index test_index_name on TestIndex (Name)"));
}