本文整理汇总了C#中TSqlObject.TryGetScript方法的典型用法代码示例。如果您正苦于以下问题:C# TSqlObject.TryGetScript方法的具体用法?C# TSqlObject.TryGetScript怎么用?C# TSqlObject.TryGetScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSqlObject
的用法示例。
在下文中一共展示了TSqlObject.TryGetScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetScript
private static string GetScript(TSqlObject procedure)
{
var script = "";
if (procedure.TryGetScript(out script))
return script;
return ""; //could throw an exception or logged this if we care??
}
示例2: DumpScript
private static void DumpScript(TSqlObject parent)
{
var script = "";
if (parent.TryGetScript(out script))
{
Console.WriteLine(script);
}
}
示例3: DumpIndex
private static void DumpIndex(TSqlObject index)
{
//Each TSqlObject has a name property:
ObjectIdentifier indexName = index.Name;
//Top level objects like tables, procedures and indexes will let you get the underlying script to generate them, doing this on things like columns fails
string script = "";
if (!index.TryGetScript(out script))
{
script = "Can only script top level objects";
}
//To get to individual properties we need to use the static schema container classes, each property can be called directly or you can ask an object for all it's child properties
var allowPageLocks = index.GetProperty<bool?>(Index.AllowPageLocks);
var isClustered = index.GetProperty<bool?>(Index.Clustered);
Console.WriteLine("Index: " + indexName);
Console.WriteLine("Properties: Is Clustered: {0}, Allow Page Locks: {1}", isClustered, allowPageLocks);
//To get the columns we need to ask for the relationships of the index and then enumerate through them
foreach (ModelRelationshipInstance column in index.GetReferencedRelationshipInstances(Index.Columns))
{
DumpColumn(column, "Column");
}
//Included columns are referenced using the relationships but are a slightly different class
foreach (ModelRelationshipInstance column in index.GetReferencedRelationshipInstances(Index.IncludedColumns))
{
DumpColumn(column, "Included");
}
Console.WriteLine("Script:");
Console.WriteLine(script);
Console.WriteLine("===============================");
}
示例4: GetScript
private string GetScript(TSqlObject table)
{
var script = "";
if (!table.TryGetScript(out script))
{
script = "Object doesn't have script, see top level object instead";
}
return script;
}