本文整理汇总了C#中DatabaseSchemaReader.SqlGen.DdlGeneratorFactory.WriteToScript方法的典型用法代码示例。如果您正苦于以下问题:C# DdlGeneratorFactory.WriteToScript方法的具体用法?C# DdlGeneratorFactory.WriteToScript怎么用?C# DdlGeneratorFactory.WriteToScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSchemaReader.SqlGen.DdlGeneratorFactory
的用法示例。
在下文中一共展示了DdlGeneratorFactory.WriteToScript方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunSprocs
public bool RunSprocs(DirectoryInfo directory, SqlType dialect, DatabaseTable table)
{
if (table == null)
{
Message = "No table";
return false;
}
var gen = new DdlGeneratorFactory(dialect).ProcedureGenerator(table);
if (gen == null)
{
//there is no sproc provider (SQLite)
Message = @"There is no sproc generator";
return false;
}
var path = Path.Combine(directory.FullName, table.Name + "_sprocs.sql");
try
{
gen.WriteToScript(path);
Message = @"Wrote " + path;
return true;
}
catch (Exception exception)
{
Message =
@"An error occurred while creating the script.\n" + exception.Message;
}
return false;
}
示例2: TestWritingCrudSprocs
public void TestWritingCrudSprocs()
{
var table = LoadCategoriesFromNorthwind();
//let's create the SQLServer crud procedures
var gen = new DdlGeneratorFactory(SqlType.SqlServer).ProcedureGenerator(table);
gen.ManualPrefix = table.Name + "__";
var destination = TestHelper.CreateDirectory("sql").FullName;
var path = Path.Combine(destination, "sqlserver_sprocs.sql");
gen.WriteToScript(path);
var txt = File.ReadAllText(path);
Assert.IsFalse(string.IsNullOrEmpty(txt), "Should have written some text");
//manually check the script is ok
}
示例3: TestWritingCrudSprocsWithOracleConversion
public void TestWritingCrudSprocsWithOracleConversion()
{
var table = LoadCategoriesFromNorthwind();
//let's pretend it's an oracle table and create an oracle package
var oracleGen = new DdlGeneratorFactory(SqlType.Oracle).ProcedureGenerator(table);
oracleGen.ManualPrefix = table.Name + "__";
//here i want all my parameters prefixed by a p
oracleGen.FormatParameter = name => "p_" + name;
//also define the cursor parameter
oracleGen.CursorParameterName = "p_cursor";
var destination = TestHelper.CreateDirectory("sql").FullName;
var oraclePath = Path.Combine(destination, "oracle_sprocs.sql");
oracleGen.WriteToScript(oraclePath);
var txt = File.ReadAllText(oraclePath);
Assert.IsFalse(string.IsNullOrEmpty(txt), "Should have written some text");
//manually check the script is ok
}