本文整理汇总了C#中TSqlObject类的典型用法代码示例。如果您正苦于以下问题:C# TSqlObject类的具体用法?C# TSqlObject怎么用?C# TSqlObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TSqlObject类属于命名空间,在下文中一共展示了TSqlObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnAnalyze
protected override IEnumerable<SqlRuleProblem> OnAnalyze(string name, TSqlObject table)
{
//Get the indexes of the table
var indexes = table.GetReferencing(Index.IndexedObject);
if (indexes.Count() == 0)
yield return new SqlRuleProblem(string.Format("The anchor table {0} has no index", name), table);
//Ensure that one of them is effecively not a clustered index
var nonClusturedIndexes = indexes.Where(i => !i.GetProperty<bool>(Index.Clustered) && i.GetProperty<bool>(Index.Unique));
if (nonClusturedIndexes == null)
yield return new SqlRuleProblem(string.Format("No existing non-clustered unique index for the anchor table {0}", name), table);
else
{
//Ensure that at least one of them is name BK
var bkIndexes = nonClusturedIndexes.Where(i => i.Name.Parts.Last().StartsWith(Configuration.Anchor.BusinessKeyPrefix));
if (bkIndexes.Count()==0)
yield return new SqlRuleProblem(string.Format("None of the non-clustered unique indexes for the anchor table {0} are starting by BK_", name), table);
else
{
foreach (var bkIndex in bkIndexes)
{
//Ensure that the unique index is not active on the identity column
var columns = bkIndex.GetReferenced(Index.Columns).Where(c => c.GetProperty<bool>(Column.IsIdentity));
if (columns.Count()>0)
yield return new SqlRuleProblem(string.Format("The business key (non-clustered unique index) {1} for the anchor table {0} contains the identity column.", name, bkIndex.Name), table);
//By default SQL Server will include the indentity column (because this column should be the clustered index)
var includedColumns = bkIndex.GetReferenced(Index.IncludedColumns).Where(c => c.GetProperty<bool>(Column.IsIdentity));
if (includedColumns.Count() > 0)
yield return new SqlRuleProblem(string.Format("The business key (non-clustered unique index) {1} for the anchor table {0} includes the identity column.", name, bkIndex.Name), table);
}
}
}
}
示例2: GetDataType
private SqlDataType GetDataType(TSqlObject something)
{
TSqlObject dataType = something.GetReferenced(Column.DataType).SingleOrDefault();
if (dataType == null)
{
return SqlDataType.Unknown;
}
// Some data types don't cleanly convert
switch (dataType.Name.Parts.Last())
{
case "hierarchyid":
case "geometry":
case "geography":
return SqlDataType.Variant;
}
// Note: User Defined Data Types (UDDTs) are not supported during deployment of memory optimized tables.
// The code below handles UDDTs in order to show how properties of a UDDT should be accessed and because
// the model validation does not actually block this syntax at present there are tests that validate this behavior.
// User Defined Data Types and built in types are merged in the public model.
// We want to examine the built in type: for user defined data types this will be
// found by accessing the DataType.Type object, which will not exist for a built in type
TSqlObject builtInType = dataType.GetReferenced(DataType.Type).SingleOrDefault();
if (builtInType != null)
{
dataType = builtInType;
}
return dataType.GetProperty<SqlDataType>(DataType.SqlDataType);
}
示例3: OnAnalyze
protected override IEnumerable<SqlRuleProblem> OnAnalyze(string name, TSqlObject table)
{
//Get the indexes of the table
var indexes = table.GetReferencing(Index.IndexedObject);
if (indexes.Count() == 0)
yield return new SqlRuleProblem(string.Format("The info table {0} has no index", name), table);
//Ensure that one of them is effecively a clustered index
var clusteredIndex = indexes.FirstOrDefault(i => i.GetProperty<bool>(Index.Clustered));
if (clusteredIndex == null)
yield return new SqlRuleProblem(string.Format("No clustered index for the info table {0}", name), table);
else
{
//Ensure that this index is effectively unique
var uniqueClusturedIndex = indexes.FirstOrDefault(i => i.GetProperty<bool>(Index.Clustered) && i.GetProperty<bool>(Index.Unique));
if (uniqueClusturedIndex == null)
yield return new SqlRuleProblem(string.Format("Clustured index for the info table {0} is not unique ", name), table);
else
{
//Ensure that the clustered index is active only on the identity column
var columns = uniqueClusturedIndex.GetReferenced(Index.Columns);
if (columns.Count() > 1)
yield return new SqlRuleProblem(string.Format("The info table {0} has a clustered index but this index has more than one column.", name), table);
if (columns.Count(c => c.GetProperty<bool>(Column.IsIdentity)) == 0)
yield return new SqlRuleProblem(string.Format("The info table {0} has a clustered index but this index doesn't include the identity column.", name), table);
}
}
}
示例4: 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??
}
示例5: DumpScript
private static void DumpScript(TSqlObject parent)
{
var script = "";
if (parent.TryGetScript(out script))
{
Console.WriteLine(script);
}
}
示例6: GetElementName
/// <summary>
/// Gets a formatted element name
/// </summary>
public static string GetElementName(TSqlObject modelElement, SqlRuleExecutionContext ruleExecutionContext, ElementNameStyle style)
{
// Get the element name using the built in DisplayServices. This provides a number of useful formatting options to
// make a name user-readable
var displayServices = ruleExecutionContext.SchemaModel.DisplayServices;
string elementName = displayServices.GetElementName(modelElement, style);
return elementName;
}
示例7: IsAnchor
protected bool IsAnchor(TSqlObject table)
{
return
table.Name.HasName
&& table.Name.Parts.Reverse().Take(2).Last().Equals(Configuration.Anchor.Schema, StringComparison.OrdinalIgnoreCase)
&& table.Name.Parts.Last().StartsWith(Configuration.Anchor.Prefix, StringComparison.OrdinalIgnoreCase)
&& table.Name.Parts.Last().EndsWith(Configuration.Anchor.Suffix, StringComparison.OrdinalIgnoreCase);
}
示例8: GetElementName
private static string GetElementName(SqlRuleExecutionContext ruleExecutionContext, TSqlObject modelElement)
{
// Get the element name using the built in DisplayServices. This provides a number of
// useful formatting options to
// make a name user-readable
var displayServices = ruleExecutionContext.SchemaModel.DisplayServices;
string elementName = displayServices.GetElementName(modelElement, ElementNameStyle.EscapedFullyQualifiedName);
return elementName;
}
示例9: IsDateTime2WithExcessiveScale
private bool IsDateTime2WithExcessiveScale(TSqlObject column)
{
var dataType = GetDataType(column);
var scale = column.GetProperty<int>(Column.Scale);
return (dataType == SqlDataType.DateTime2 && scale > 2);
}
示例10: HasParameterBeenRemoved
private static bool HasParameterBeenRemoved(ModelRelationshipInstance parameter, TSqlObject oldProcedure)
{
/*
A parameter does not exist in the old model
*/
return
oldProcedure.GetReferencedRelationshipInstances(Procedure.Parameters)
.FirstOrDefault(p => p.ObjectName.Parts.Last() == parameter.ObjectName.Parts.Last()) == null;
}
示例11: ShowColumnsDataType
private static void ShowColumnsDataType(TSqlObject table)
{
foreach (var child in table.GetReferencedRelationshipInstances(Table.Columns))
{
var type = child.Object.GetReferenced(Column.DataType).FirstOrDefault();
var isNullable = type.GetProperty<bool?> (DataType.UddtNullable);
var length = type.GetProperty<int?>(DataType.UddtLength);
//do something useful with this information!
}
}
示例12: OnAnalyze
protected override IEnumerable<SqlRuleProblem> OnAnalyze(string name, TSqlObject table)
{
//Get the columns of the table
var columns = table.GetReferenced(Table.Columns);
if (columns.Count() == 0)
yield return new SqlRuleProblem(string.Format("The link table {0} has no column", name), table);
//Ensure that one of them is effecively a DateId
var timeBasedColumn = columns.FirstOrDefault(i => i.Name.Parts.Last() == Configuration.TimeBased.Key);
if (timeBasedColumn == null)
yield return new SqlRuleProblem(string.Format("No column named '{0}' for link table {1}", Configuration.TimeBased.Key, name), table);
}
示例13: DoSmells
private IList<SqlRuleProblem> DoSmells(TSqlObject SqlObject)
{
List<SqlRuleProblem> problems = new List<SqlRuleProblem>();
Smells smellprocess = new Smells();
int iRule = int.Parse(_ruleID.Substring(_ruleID.Length - 3));
return (smellprocess.ProcessObject(SqlObject, iRule));
}
示例14: DumpChildren
static void DumpChildren(TSqlObject parent, int depth)
{
DumpScript(parent);
foreach (var property in parent.ObjectType.Properties)
{
DumpProperty(property, parent);
}
foreach (var child in parent.GetChildren())
{
DumpChildren(child, depth + 1);
}
}
示例15: Add
public bool Add(string root, string name, TSqlObject item)
{
if (!SeemItems.ContainsKey(root))
{
SeemItems[root] = new Dictionary<string, TSqlObject>();
}
if (SeemItems[root].ContainsKey(name))
return false;
SeemItems[root][name] = item;
return true;
}