本文整理汇总了C#中NHibernate.Cfg.Configuration.GenerateDropSchemaScript方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.GenerateDropSchemaScript方法的具体用法?C# Configuration.GenerateDropSchemaScript怎么用?C# Configuration.GenerateDropSchemaScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.GenerateDropSchemaScript方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchemaExport
/// <summary>
/// Create a schema exporter for the given Configuration, with the given
/// database connection properties
/// </summary>
/// <param name="cfg">The NHibernate Configuration to generate the schema from.</param>
/// <param name="connectionProperties">The Properties to use when connecting to the Database.</param>
public SchemaExport(Configuration cfg, IDictionary<string, string> connectionProperties)
{
this.connectionProperties = connectionProperties;
dialect = Dialect.Dialect.GetDialect(connectionProperties);
dropSQL = cfg.GenerateDropSchemaScript(dialect);
createSQL = cfg.GenerateSchemaCreationScript(dialect);
}
示例2: SchemaExport
/// <summary>
/// Create a schema exporter for the given Configuration, with the given
/// database connection properties
/// </summary>
/// <param name="cfg">The NHibernate Configuration to generate the schema from.</param>
/// <param name="configProperties">The Properties to use when connecting to the Database.</param>
public SchemaExport(Configuration cfg, IDictionary<string, string> configProperties)
{
this.configProperties = configProperties;
dialect = Dialect.Dialect.GetDialect(configProperties);
dropSQL = cfg.GenerateDropSchemaScript(dialect);
createSQL = cfg.GenerateSchemaCreationScript(dialect);
formatter = (PropertiesHelper.GetBoolean(Environment.FormatSql, configProperties, true) ? FormatStyle.Ddl : FormatStyle.None).Formatter;
}
示例3: BuildSchema
public void BuildSchema(ISession session, Configuration configuration)
{
IDbConnection connection = session.Connection;
Dialect dialect = Dialect.GetDialect(configuration.Properties);
string[] drops = configuration.GenerateDropSchemaScript(dialect);
ExecuteScripts(drops, connection);
string[] scripts = configuration.GenerateSchemaCreationScript(dialect);
ExecuteScripts(scripts, connection);
}
示例4: LiveSqliteSchema
static LiveSqliteSchema()
{
var config = new Configuration();
config.SetProperty(Environment.Dialect, "NHibernate.Dialect.SQLiteDialect");
config.AddInputStream(HbmSerializer.Default.Serialize(Assembly.Load("tanzer.lotto.core")));
Dialect dialect = Dialect.GetDialect(config.Properties);
// pause at critical moments; row COUNT; rollback journal; isolation level
// @sa http://www.sqlite.org/pragma.html
script = "PRAGMA synchronous=FALSE;PRAGMA count_changes=FALSE;PRAGMA journal_mode=FALSE;PRAGMA read_uncommitted=TRUE;";
script += String.Join(";", config.GenerateDropSchemaScript(dialect));
script += ";";
script += String.Join(";", config.GenerateSchemaCreationScript(dialect));
script += ";";
}
示例5: Main
static int Main(string[] args)
{
try
{
log4net.Config.XmlConfigurator.Configure();
string scriptDir = Settings.Default.ScriptsDir;
if (!Path.IsPathRooted (scriptDir))
{
scriptDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, scriptDir);
}
Console.WriteLine("Generating script...");
Configuration cfg = new Configuration();
cfg.Configure();
Dialect dialect = Dialect.GetDialect(cfg.Properties);
string[] dropStatements = cfg.GenerateDropSchemaScript(dialect);
string[] createStatements = cfg.GenerateSchemaCreationScript(dialect);
using (StreamWriter writer = new StreamWriter(Path.Combine(scriptDir, Settings.Default.ScriptToGenerate), false, Encoding.Default))
{
foreach (string s in dropStatements)
{
string f = Format(ParseDropConstraint(s));
writer.WriteLine(f);
}
writer.WriteLine();
foreach (string s in createStatements)
{
string f = Format(ParseCreateTable(s));
writer.WriteLine(f);
}
foreach (string scriptToAppend in Settings.Default.ScriptsToAppend)
{
writer.WriteLine();
writer.WriteLine(File.ReadAllText(Path.Combine(scriptDir, scriptToAppend),Encoding.Default));
}
}
Console.WriteLine("Done");
}
catch (Exception e)
{
log.Error(e);
Console.WriteLine(e);
return 1;
}
return 0;
}
示例6: ExportDropeSchema
public static string[] ExportDropeSchema(Dialect dialect)
{
Configuration cfg = new Configuration();
cfg.Configure();
return cfg.GenerateDropSchemaScript(dialect);
}