本文整理汇总了C#中NHibernate.Tool.hbm2ddl.SchemaExport.SetOutputFile方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaExport.SetOutputFile方法的具体用法?C# SchemaExport.SetOutputFile怎么用?C# SchemaExport.SetOutputFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Tool.hbm2ddl.SchemaExport
的用法示例。
在下文中一共展示了SchemaExport.SetOutputFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NHibernateManager
/// <summary>
/// Initiate NHibernate Manager
/// </summary>
/// <param name="connect">NHibernate dialect, driver and connection string separated by ';'</param>
/// <param name="store">Name of the store</param>
public NHibernateManager(string connect, string store)
{
try
{
ParseConnectionString(connect);
//To create sql file uncomment code below and write the name of the file
SchemaExport exp = new SchemaExport(configuration);
exp.SetOutputFile("db_creation.sql");
exp.Create(false, true);
sessionFactory = configuration.BuildSessionFactory();
}
catch (MappingException mapE)
{
if (mapE.InnerException != null)
Console.WriteLine("[NHIBERNATE]: Mapping not valid: {0}, {1}, {2}", mapE.Message, mapE.StackTrace, mapE.InnerException.ToString());
else
m_log.ErrorFormat("[NHIBERNATE]: Mapping not valid: {0}, {1}", mapE.Message, mapE.StackTrace);
}
catch (HibernateException hibE)
{
Console.WriteLine("[NHIBERNATE]: HibernateException: {0}, {1}", hibE.Message, hibE.StackTrace);
}
catch (TypeInitializationException tiE)
{
Console.WriteLine("[NHIBERNATE]: TypeInitializationException: {0}, {1}", tiE.Message, tiE.StackTrace);
}
}
示例2: CreateSchemaExport
private SchemaExport CreateSchemaExport(Configuration config)
{
var result = new SchemaExport(config);
if (!string.IsNullOrEmpty(this.delimiter)) result.SetDelimiter(this.delimiter);
if (!string.IsNullOrEmpty(this.outputFile)) result.SetOutputFile(this.outputFile);
return result;
}
示例3: ChangeRawConfig
/// <summary>Changes the raw NHibernate config.</summary>
/// <param name="config">The configuration to change.</param>
public void ChangeRawConfig(Configuration config)
{
var schemaExport = new SchemaExport(config);
var path = string.Empty;
if (_outputSql)
{
path = Path.Combine(Path.GetTempPath(), "NHibernate SQL");
Directory.CreateDirectory(path);
schemaExport.SetOutputFile(Path.Combine(path, "drop.sql"));
}
schemaExport.Drop(false, true);
if (_outputSql)
schemaExport.SetOutputFile(Path.Combine(path, "create.sql"));
schemaExport.Create(false, true);
}
示例4: CreateSchema
static void CreateSchema()
{
SchemaExport export = new SchemaExport(m_NHConfiguration);
export.SetDelimiter(";");
export.SetOutputFile(@"db.sql").Execute(false, false, false);
Console.WriteLine("Schema Exported");
}
示例5: btnGenerateDBScript_Click
private void btnGenerateDBScript_Click(object sender, RoutedEventArgs e)
{
Assembly assembly = Assembly.LoadFrom(txtFileName.Text);
IPersistenceConfigurer databaseConfig = null;
string fileName = "Domain Database Script - {0}.sql";
if (rdbSqlServer.IsChecked != null)
if (rdbSqlServer.IsChecked.Value)
{
databaseConfig = MsSqlConfiguration.MsSql2005;
fileName = string.Format(fileName, "Sql Server 2005");
}
else if (rdbOracle.IsChecked != null)
if (rdbOracle.IsChecked.Value)
{
databaseConfig = OracleDataClientConfiguration.Oracle9;
fileName = string.Format(fileName, "Oracle 9g");
}
Fluently.Configure()
.Mappings(m => m.FluentMappings.AddFromAssembly(assembly))
.Database(databaseConfig)//.ConnectionString("Data Source=.\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True"))
.ExposeConfiguration(config =>
{
SchemaExport se = new SchemaExport(config);
se.SetOutputFile(fileName);
se.Create(false, false);
MessageBox.Show(string.Format("Script successful created! See the '{0}' file.", fileName));
}).BuildConfiguration();
}
示例6: CreateDatabase
/// <summary>
/// Generate the database schema, apply it to the database and save the DDL used into a file.
/// </summary>
public static void CreateDatabase()
{
Configuration configuration = new Configuration();
configuration.Configure();
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.SetOutputFile("SQLite database schema.ddl");
schemaExport.Create(true, true);
}
示例7: CreateSchema
public void CreateSchema()
{
var nhConfig = new ConfigurationBuilder().Build();
var schemaExport = new SchemaExport(nhConfig);
schemaExport
.SetOutputFile(@"db.sql")
.Execute(false, false, false);
}
示例8: createDatabase
public static void createDatabase()
{
var nhconfig = new Configuration().Configure();
var sessionFactory = nhconfig.BuildSessionFactory();
var schemaExport = new SchemaExport(nhconfig);
schemaExport.SetOutputFile(@"concepts.sql")
.Execute(true, true, false);
Console.WriteLine("I created your database");
}
示例9: TestGenerationOfSchema
public void TestGenerationOfSchema()
{
Configuration configuration = new Configuration();
configuration.Configure();
configuration.AddAssembly(typeof(State).Assembly);
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.SetOutputFile("schema.sql");
schemaExport.Execute(false, true, false);
}
示例10: Create_Database
public void Create_Database()
{
Configuration config = sessionBuilder.GetConfiguration();
var exporter = new SchemaExport(config);
exporter.SetOutputFile(@"C:\temp\GroopSchema.ddl");
exporter.Create(true, false);
}
示例11: DropAndRecreateSchema
private void DropAndRecreateSchema()
{
SchemaExport schemaExport = new SchemaExport(this.configuration);
schemaExport.SetOutputFile(@"..\..\nhibernate-schema.txt");
schemaExport.Drop(script: false, export: true);
schemaExport.Create(script: false, export: true);
}
示例12: CreatSchema
public static void CreatSchema(string OutputFile, string ConnString)
{
FNHMVC.Data.Infrastructure.ConnectionHelper.GetConfiguration(ConnString).ExposeConfiguration(cfg =>
{
var schemaExport = new NHibernate.Tool.hbm2ddl.SchemaExport(cfg);
if (!string.IsNullOrEmpty(OutputFile)) schemaExport.SetOutputFile(OutputFile);
schemaExport.Drop(false, true);
schemaExport.Create(false, true);
}).BuildConfiguration();
}
示例13: Generate
public void Generate()
{
var databaseSchemaFileName = GetDatabaseSchemaFileName();
File.Delete(databaseSchemaFileName);
var nHibernateConfigurator = GetNhibernateConfigurator();
var schemaExport = new SchemaExport(nHibernateConfigurator.GetConfiguration());
schemaExport.SetOutputFile(databaseSchemaFileName);
schemaExport.Create(true, false);
if (!File.Exists(databaseSchemaFileName) || new FileInfo(databaseSchemaFileName).Length == 0) throw new Exception("Error generating database schema");
}
示例14: Should_save_schema_to_file
public void Should_save_schema_to_file()
{
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof(Product).Assembly);
var schemaExport = new SchemaExport(cfg);
schemaExport.SetOutputFile("../../GeneratedSchema/schema.sql");
schemaExport.Create(true, true);
}
示例15: Main
static void Main(string[] args)
{
var nhConfig = new Configuration().Configure();
var sessionFactory = nhConfig.BuildSessionFactory();
var schemaExport = new SchemaExport(nhConfig);
schemaExport
.SetOutputFile(@"db.sql")
.Execute(false, false, false);
}