本文整理汇总了C#中TSqlObject类的典型用法代码示例。如果您正苦于以下问题:C# TSqlObject类的具体用法?C# TSqlObject怎么用?C# TSqlObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TSqlObject类属于命名空间,在下文中一共展示了TSqlObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:34,代码来源:BusinessKeyIndexAnchor.cs
示例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);
}
开发者ID:DidItSave,项目名称:CustomCodeRulesForSSDT,代码行数:34,代码来源:DateTimeColumnsWith7ScaleRule.cs
示例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);
}
}
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:29,代码来源:ClusturedIndexInfo.cs
示例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??
}
开发者ID:modulexcite,项目名称:DacFxApi,代码行数:8,代码来源:Program.cs
示例5: DumpScript
private static void DumpScript(TSqlObject parent)
{
var script = "";
if (parent.TryGetScript(out script))
{
Console.WriteLine(script);
}
}
开发者ID:GoEddie,项目名称:DacpacExplorer,代码行数:8,代码来源:Program.cs
示例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;
}
开发者ID:GoEddie,项目名称:DACExtensions,代码行数:11,代码来源:RuleUtils.cs
示例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);
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:8,代码来源:BaseAnchor.cs
示例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;
}
开发者ID:Seddryck,项目名称:SSDT-on-steroids,代码行数:9,代码来源:DimensionWithIdentityRule.cs
示例9: IsDateTime2WithExcessiveScale
private bool IsDateTime2WithExcessiveScale(TSqlObject column)
{
var dataType = GetDataType(column);
var scale = column.GetProperty<int>(Column.Scale);
return (dataType == SqlDataType.DateTime2 && scale > 2);
}
开发者ID:DidItSave,项目名称:CustomCodeRulesForSSDT,代码行数:9,代码来源:DateTimeColumnsWith7ScaleRule.cs
示例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;
}
开发者ID:GoEddie,项目名称:Contributors,代码行数:10,代码来源:DeploymentFilter.cs
示例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!
}
}
开发者ID:modulexcite,项目名称:DacFxApi,代码行数:11,代码来源:Program.cs
示例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);
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:12,代码来源:TimeBasedColumnLink.cs
示例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));
}
开发者ID:dalehhirt,项目名称:TSQL-Smells,代码行数:12,代码来源:TSQLSmellSCA.cs
示例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);
}
}
开发者ID:GoEddie,项目名称:DacpacExplorer,代码行数:13,代码来源:Program.cs
示例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;
}
开发者ID:GoEddie,项目名称:DacpacExplorer,代码行数:13,代码来源:RecursionGuard.cs
示例16: AddPropertiesForIndex
private void AddPropertiesForIndex(Panel panel, TSqlObject index)
{
foreach (var reference in index.GetReferencedRelationshipInstances(Index.Columns))
{
panel.Children.Add(GetPropertyLabel("Column: ", reference.ObjectName + " " + (reference.GetProperty<bool>(Index.ColumnsRelationship.Ascending) ? "ASC" : "DESC")));
}
if (index.GetReferencedRelationshipInstances(Index.IncludedColumns).Any())
{
foreach (var reference in index.GetReferencedRelationshipInstances(Index.IncludedColumns))
{
panel.Children.Add(GetPropertyLabel("Included Column: ", reference.ObjectName.ToString()));
}
}
}
开发者ID:GoEddie,项目名称:DacpacExplorer,代码行数:16,代码来源:PropertiesPageBuilder.cs
示例17: OnAnalyze
protected override IEnumerable<SqlRuleProblem> OnAnalyze(string name, TSqlObject table)
{
var indexes = table.GetReferencing(Index.IndexedObject);
var firstTimeIndexes = indexes.Where(i => i.GetReferenced(Index.Columns).First().Name.Parts.Last()
== Configuration.Link.IsFirst);
if (firstTimeIndexes.Count() == 0)
yield return new SqlRuleProblem(string.Format("No index where is-first column is '{0}' for link table {1}", Configuration.TimeBased.Key, name), table);
foreach (var fIndex in firstTimeIndexes)
{
var indexColumns = fIndex.GetReferenced(Index.Columns).Where(c => c.Name.Parts.Last() != Configuration.TimeBased.Key);
var includedColumns = fIndex.GetReferenced(Index.IncludedColumns);
var allColumns = indexColumns.Union(includedColumns);
if (allColumns.Count() == 0)
yield return new SqlRuleProblem(string.Format("The time-based index {0} for link table {1} has no additional or included columns", fIndex.Name, name), table);
yield return new SqlRuleProblem(string.Format("The time-based index {0} for link table {1} has no additional or included columns", fIndex.Name, name), table);
}
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:19,代码来源:HeapLink.cs
示例18: HasDefaultValueBeenRemoved
private bool HasDefaultValueBeenRemoved(ModelRelationshipInstance parameter, TSqlObject oldProcedure)
{
var newParameterHasDefault = parameter.Object.GetProperty(Parameter.DefaultExpression) != null;
var parameterInOldModel =
oldProcedure.GetReferencedRelationshipInstances(Procedure.Parameters)
.FirstOrDefault(p => p.ObjectName.Parts.Last() == parameter.ObjectName.Parts.Last());
/*
A parameter in the new model has no default but it had a default in the old model...
*/
if (parameterInOldModel != null && !newParameterHasDefault && (parameterInOldModel.Object.GetProperty(Parameter.DefaultExpression) != null))
{
return true;
}
return false;
}
开发者ID:GoEddie,项目名称:Contributors,代码行数:19,代码来源:DeploymentFilter.cs
示例19: HasParameterBeenAddedWithoutDefaultValue
private static bool HasParameterBeenAddedWithoutDefaultValue(ModelRelationshipInstance parameter,
TSqlObject newProcedure)
{
var hasDefault = parameter.Object.GetProperty(Parameter.DefaultExpression) != null;
var parameterInOldModel =
newProcedure.GetReferencedRelationshipInstances(Procedure.Parameters)
.FirstOrDefault(p => p.ObjectName.Parts.Last() == parameter.ObjectName.Parts.Last());
/*
A parameter did not exist in the old model and has no default
*/
if (parameterInOldModel == null && !hasDefault)
{
return true;
}
return false;
}
开发者ID:GoEddie,项目名称:Contributors,代码行数:20,代码来源:DeploymentFilter.cs
示例20: OnAnalyze
protected override IEnumerable<SqlRuleProblem> OnAnalyze(string name, TSqlObject table)
{
var indexes = table.GetReferencing(Index.IndexedObject);
var timeBasedIndexes = indexes.Where(i => i.GetReferenced(Index.Columns).First().Name.Parts.Last()
== Configuration.TimeBased.Key);
if (timeBasedIndexes.Count() == 0)
yield return new SqlRuleProblem(string.Format("No index where first column is '{0}' for link table {1}", Configuration.TimeBased.Key, name), table);
foreach (var tbIndex in timeBasedIndexes)
{
var unexpectedColumns = tbIndex.GetReferenced(Index.Columns).Where(c => c.Name.Parts.Last() != Configuration.TimeBased.Key);
if (unexpectedColumns.Count()>0)
{
yield return new SqlRuleProblem(
string.Format(
"The time-based index '{0}' for link table '{1}' contains additional columns. Unexpected column{2} '{3}'"
, tbIndex.Name
, name
, (unexpectedColumns.Count() == 1) ? " is " : "s are "
, string.Join("', '", unexpectedColumns.Select(c => c.Name.Parts.Last()))
), table);
}
var idColumns = table.GetReferenced(Table.Columns).Where(c => c.Name.Parts.Last() != Configuration.TimeBased.Key && c.Name.Parts.Last().EndsWith("Id"));
var includedColumns = tbIndex.GetReferenced(Index.IncludedColumns);
var missingColumns = idColumns.Except(includedColumns);
if (missingColumns.Count()>0)
{
yield return new SqlRuleProblem(
string.Format(
"The time-based index '{0}' for link table '{1}' doesn't include some Id columns. Missing column{2} '{3}'"
, tbIndex.Name
, name
, (missingColumns.Count() == 1) ? " is " : "s are "
, string.Join("', '", missingColumns.Select(c => c.Name.Parts.Last()))
), table);
}
}
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:41,代码来源:TimeBasedIndexLink.cs
注:本文中的TSqlObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论