本文整理汇总了C#中TSqlObject.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# TSqlObject.GetProperty方法的具体用法?C# TSqlObject.GetProperty怎么用?C# TSqlObject.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSqlObject
的用法示例。
在下文中一共展示了TSqlObject.GetProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsDateTime2WithExcessiveScale
private bool IsDateTime2WithExcessiveScale(TSqlObject column)
{
var dataType = GetDataType(column);
var scale = column.GetProperty<int>(Column.Scale);
return (dataType == SqlDataType.DateTime2 && scale > 2);
}
示例2: 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("===============================");
}
示例3: GetSchemaForColumn
private static ColumnInfo GetSchemaForColumn(TSqlObject model)
{
TSqlObject type = model.GetReferenced(Column.DataType).First();
string dataType = type.Name.Parts[0];
bool isNullable = model.GetProperty<bool>(Column.Nullable);
int length = model.GetProperty<int>(Column.Length);
return new ColumnInfo
{
Name = model.Name.Parts[2],
FullName = model.Name.ToString(),
SqlDataType = dataType,
ClrType = GetTypeMapping(dataType, isNullable),
Nullable = isNullable,
Length = length
};
}
示例4: ValidateViewHasSchemaBinding
/// <summary>
// Views must be schema bound if they reference a memory optimized table
/// </summary>
private static void ValidateViewHasSchemaBinding(SqlRuleExecutionContext context, TSqlObject view, TSqlObject table,
IList<SqlRuleProblem> problems)
{
if (!view.GetProperty<bool>(View.WithSchemaBinding))
{
string description = string.Format(CultureInfo.CurrentCulture,
RuleResources.ViewsOnMemoryOptimizedTable_SchemaBindingProblemDescription,
RuleUtils.GetElementName(context, view),
RuleUtils.GetElementName(context, table));
TSqlFragment nameFragment = TsqlScriptDomUtils.LookupSchemaObjectName(view);
problems.Add(new SqlRuleProblem(description, view, nameFragment));
}
}