本文整理汇总了C#中DatabaseSchemaReader.SqlGen.DdlGeneratorFactory.Write方法的典型用法代码示例。如果您正苦于以下问题:C# DdlGeneratorFactory.Write方法的具体用法?C# DdlGeneratorFactory.Write怎么用?C# DdlGeneratorFactory.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSchemaReader.SqlGen.DdlGeneratorFactory
的用法示例。
在下文中一共展示了DdlGeneratorFactory.Write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWritingNorthwindTables
public void TestWritingNorthwindTables()
{
var schemas = LoadCategoriesFromNorthwind().DatabaseSchema;
//take a SQLServer Northwind and write all the tables and relations
var gen = new DdlGeneratorFactory(SqlType.SqlServer).AllTablesGenerator(schemas);
var txt = gen.Write();
Assert.IsFalse(string.IsNullOrEmpty(txt), "Should have written some text");
//let's translate it into Oracle.
var oracleGen = new DdlGeneratorFactory(SqlType.Oracle).AllTablesGenerator(schemas);
oracleGen.IncludeSchema = false; //we don't want "dbo." prefixes
txt = oracleGen.Write();
Assert.IsFalse(string.IsNullOrEmpty(txt), "Should have written some text");
//let's translate it into MySQL.
var mysqlGen = new DdlGeneratorFactory(SqlType.MySql).AllTablesGenerator(schemas);
mysqlGen.IncludeSchema = false; //we don't want "dbo." prefixes
var mySqlTxt = mysqlGen.Write();
Assert.IsFalse(string.IsNullOrEmpty(mySqlTxt), "Should have written some text");
//let's translate it into SQLite.
var sqliteGen = new DdlGeneratorFactory(SqlType.SQLite).AllTablesGenerator(schemas);
sqliteGen.IncludeSchema = false; //we don't want "dbo." prefixes
var sqliteTxt = sqliteGen.Write();
Assert.IsFalse(string.IsNullOrEmpty(sqliteTxt), "Should have written some text");
//manually check the script is ok
}
示例2: RunTableDdl
public bool RunTableDdl(DirectoryInfo directory, SqlType dialect)
{
var tg = new DdlGeneratorFactory(dialect).AllTablesGenerator(_databaseSchema);
tg.IncludeSchema = false;
string txt;
try
{
txt = tg.Write();
}
catch (Exception exception)
{
Message =
@"An error occurred while creating the script.\n" + exception.Message;
return false;
}
try
{
var path = Path.Combine(directory.FullName, "table.sql");
File.WriteAllText(path, txt);
Message = @"Wrote " + path;
return true;
}
catch (Exception exception)
{
Message =
@"An IO error occurred while writing the file.\n" + exception.Message;
}
return false;
}
示例3: TestWritingSqlTableIntoOracleTable
public void TestWritingSqlTableIntoOracleTable()
{
var table = LoadCategoriesFromNorthwind();
//take a SQLServer table and create Oracle table DDL
var gen = new DdlGeneratorFactory(SqlType.Oracle).TableGenerator(table);
var txt = gen.Write();
Assert.IsFalse(string.IsNullOrEmpty(txt), "Should have written some text");
//manually check the script is ok
}
示例4: BuildAllTableDdl
public void BuildAllTableDdl(DatabaseSchema databaseSchema)
{
var tg = new DdlGeneratorFactory(_sqlType).AllTablesGenerator(databaseSchema);
tg.IncludeSchema = false;
try
{
var txt = tg.Write();
Clipboard.SetText(txt, TextDataFormat.UnicodeText);
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
}