本文整理汇总了C#中NHibernate.Tool.hbm2ddl.SchemaExport.SetDelimiter方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaExport.SetDelimiter方法的具体用法?C# SchemaExport.SetDelimiter怎么用?C# SchemaExport.SetDelimiter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Tool.hbm2ddl.SchemaExport
的用法示例。
在下文中一共展示了SchemaExport.SetDelimiter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSchema
static void CreateSchema()
{
SchemaExport export = new SchemaExport(m_NHConfiguration);
export.SetDelimiter(";");
export.SetOutputFile(@"db.sql").Execute(false, false, false);
Console.WriteLine("Schema Exported");
}
示例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: Index
// GET: /Admin/
public ActionResult Index()
{
var se = new SchemaExport((new Configuration()).Configure());
se.SetDelimiter(";\n");
TextWriter oldOut = Console.Out;
var creationSchema = new StringWriter();
Console.SetOut(creationSchema);
se.Create(true, false);
Console.SetOut(oldOut);
ViewBag.SchemaExport = creationSchema.ToString();
return View();
}
示例4: CriarSchema
public void CriarSchema()
{
Configuration configuration = SessionFactory.Configuration();
var schemaExport = new SchemaExport(configuration);
using (TextWriter stringWriter = new StreamWriter("C:\\exemploNH.sql"))
{
schemaExport.SetDelimiter(";");
schemaExport.Execute(true, false, false, null, stringWriter);
}
// Depois de criar as tabelas no MySQL, altere o Storage Engine delas para
// InnoDB, assim vc tem suporte a transações (MyISAM, q é o padrão, não suporta).
// Vc pode fazer isso por comandos sql: 'ALTER TABLE motoristas ENGINE=InnoDB;'
}
示例5: ExportSchema
/// <summary>
///
/// </summary>
/// <param name="cfg"></param>
/// <param name="outputFileName"></param>
/// <param name="script"></param>
/// <param name="export"></param>
/// <param name="justDrop"></param>
public static void ExportSchema(Configuration cfg, string outputFileName, bool script, bool export, bool justDrop)
{
SchemaExport exporter = new SchemaExport(cfg);
//exporter.SetOutputFile(outputFileName);
exporter.SetDelimiter(";");
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outputFileName, false, Encoding.UTF8))
{
Console.SetOut(sw);
exporter.Execute(script, export, justDrop);
}
//exporter.Drop(true, false); == == exporter.Execute(true, false, true, true)
//exporter.Create(true, false); == exporter.Execute(true, false, false, true)
}
示例6: AddNHibernate
public static void AddNHibernate(this IServiceCollection serviceCollection,
string type, string connectionString) {
var configuration = Fluently.Configure()
.Database(GetDatabaseConfiguration(type, connectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AccountMap>());
#if DEBUG
configuration = configuration.ExposeConfiguration(config => {
var schemaExport = new SchemaExport(config);
schemaExport.SetDelimiter(";");
schemaExport.SetOutputFile("schema.sql").Execute(true, false, false);
});
#endif
var factory = configuration.BuildSessionFactory();
serviceCollection.AddSingleton(factory);
serviceCollection.AddScoped<IScopeFactory, ScopeFactory>();
}
示例7: ExecuteTask
/// <summary>
/// Executes the task.
/// </summary>
protected override void ExecuteTask()
{
Configuration config = new Configuration();
Dictionary<string, string> properties = new Dictionary<string, string>();
properties[NHibernate.Cfg.Environment.ConnectionProvider] = ConnectionProvider;
properties[NHibernate.Cfg.Environment.Dialect] = Dialect;
properties[NHibernate.Cfg.Environment.ConnectionDriver] = ConnectionDriverClass;
properties[NHibernate.Cfg.Environment.ConnectionString] = ConnectionString;
config.AddProperties(properties);
foreach (string filename in Assemblies.FileNames)
{
Log(Level.Info, "Adding assembly file {0}", filename);
try
{
Assembly asm = Assembly.LoadFile(filename);
config.AddAssembly(asm);
}
catch (Exception e)
{
Log(Level.Error, "Error loading assembly {0}: {1}", filename, e);
}
}
SchemaExport se = new SchemaExport(config);
if (!IsStringNullOrEmpty(OutputFilename))
{
se.SetOutputFile(OutputFilename);
}
se.SetDelimiter(Delimiter);
Log(Level.Debug, "Exporting ddl schema.");
se.Execute(OutputToConsole, ExportOnly, DropOnly, FormatNice);
if (!IsStringNullOrEmpty(OutputFilename))
{
Log(Level.Info, "Successful DDL schema output: {0}", OutputFilename);
}
}
示例8: CreateSchemaExport
private static SchemaExport CreateSchemaExport(Configuration cfg)
{
SchemaExport export = new SchemaExport(cfg);
// set the delimiter, but only if it is not the default delimiter
if (schemaDelimiter != defaultSchemaDelimiter)
{
export.SetDelimiter(schemaDelimiter);
}
return export;
}