当前位置: 首页>>代码示例>>C#>>正文


C# TSqlObject.GetReferenced方法代码示例

本文整理汇总了C#中TSqlObject.GetReferenced方法的典型用法代码示例。如果您正苦于以下问题:C# TSqlObject.GetReferenced方法的具体用法?C# TSqlObject.GetReferenced怎么用?C# TSqlObject.GetReferenced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSqlObject的用法示例。


在下文中一共展示了TSqlObject.GetReferenced方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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 info table {0} has no column", name), table);

            //Ensure that one of them is effecively an identity
            var identityColumn = columns.FirstOrDefault(c => c.GetProperty<bool>(Column.IsIdentity));
            if (identityColumn == null)
                yield return new SqlRuleProblem(string.Format("No identity column for the info table {0}", name), table);
            else
            {
                if (!string.IsNullOrEmpty(Configuration.Info.IdentityNamingConvention))
                {
                    //Ensure that this column has correct naming convention
                    var actualIdentityColumnName = identityColumn.Name.Parts.Last();
                    var expectedIdentityColumnName = string.Format(Configuration.Info.IdentityNamingConvention, table.Name.Parts.Last());
                    if (string.Compare(actualIdentityColumnName, expectedIdentityColumnName, false) != 0)
                        yield return new SqlRuleProblem(string.Format("Identity column for the info table {0} doesn't follow the naming convention: '{1}' in place of '{2}'", name, actualIdentityColumnName, expectedIdentityColumnName), table);
                }
            }
        }
开发者ID:Seddryck,项目名称:Tibre,代码行数:23,代码来源:IdentityColumnInfo.cs

示例5: 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
            };
        }
开发者ID:modulexcite,项目名称:T4Generators,代码行数:17,代码来源:DatabaseSchema.cs

示例6: GetSchemaForView

        private static ViewInfo GetSchemaForView(TSqlObject model)
        {
            ViewInfo retVal = new ViewInfo();
            retVal.ShortName = model.Name.Parts[1];
            retVal.FullName = model.Name.ToString();

            var columns = model.GetReferenced(View.Columns).ToArray();
            retVal.Columns = new ColumnInfo[columns.Length];
            for (int i = 0; i < columns.Length; i++)
            {
                TSqlObject column = columns[i];
                string dataType = "nvarchar";
                bool isNullable = column.GetProperty<bool>(Column.Nullable);
                int length = column.GetProperty<int>(Column.Length);

                TSqlObject referencedColumn = column.GetReferenced().FirstOrDefault();
                if (null != referencedColumn)
                {
                    TSqlObject type = referencedColumn.GetReferenced(Column.DataType).First();
                    dataType = type.Name.Parts[0];
                }

                retVal.Columns[i] = new ColumnInfo
                {
                    Name = column.Name.Parts[2],
                    FullName = column.Name.ToString(),
                    SqlDataType = dataType,
                    ClrType = GetTypeMapping(dataType, isNullable),
                    Nullable = isNullable,
                    Length = length
                };
            }

            return retVal;
        }
开发者ID:modulexcite,项目名称:T4Generators,代码行数:35,代码来源:DatabaseSchema.cs

示例7: GetSchemaForTable

        private static TableInfo GetSchemaForTable(TSqlObject model)
        {
            TableInfo retVal = new TableInfo();
            retVal.EntityName = _pluralizationService.Singularize(model.Name.Parts[1]);
            retVal.ShortName = model.Name.Parts[1];
            retVal.FullName = model.Name.ToString();

            var columns = model.GetReferenced(Table.Columns).ToArray();
            retVal.Columns = new ColumnInfo[columns.Length];
            for (int i = 0; i < columns.Length; i++)
            {
                ColumnInfo column = GetSchemaForColumn(columns[i]);
                retVal.Columns[i] = column;
                if (columns[i].GetProperty<bool>(Column.IsIdentity))
                    retVal.IdentityColumn = column;
            }

            return retVal;
        }
开发者ID:modulexcite,项目名称:T4Generators,代码行数:19,代码来源:DatabaseSchema.cs

示例8: AddPropertiesForColumn

        private void AddPropertiesForColumn(Panel panel, TSqlObject column)
        {
            var type = column.GetMetadata<ColumnType>(Column.ColumnType);

            panel.Children.Add(GetPropertyLabel("Column MetaType: ", type == ColumnType.Column ? "Standard Column" : type.ToString()));

            foreach (TSqlObject referenced in column.GetReferenced())
            {
                panel.Children.Add(GetPropertyLabel("Type: ", referenced.Name.ToString()));
            }

        }
开发者ID:GoEddie,项目名称:DacpacExplorer,代码行数:12,代码来源:PropertiesPageBuilder.cs

示例9: IsIndexOnMemoryOptimizedTable

 private static bool IsIndexOnMemoryOptimizedTable(TSqlObject index)
 {
     TSqlObject targetTable = index.GetReferenced(Index.IndexedObject).SingleOrDefault();
     return targetTable != null
             && Table.TypeClass.Equals(targetTable.ObjectType)
             && targetTable.GetProperty<bool>(Table.MemoryOptimized);
 }
开发者ID:GoEddie,项目名称:DACExtensions,代码行数:7,代码来源:InMemoryTableBin2CollationRule.cs

示例10: IsCharacterColumn

        private static bool IsCharacterColumn(TSqlObject column)
        {
            TSqlObject dataType = column.GetReferenced(Column.DataType).SingleOrDefault();

            if (dataType == null)
            {
                return false;
            }

            // 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;
            }

            SqlDataType sqlDataType = dataType.GetProperty<SqlDataType>(DataType.SqlDataType);
            return CharacterDataTypes.Contains(sqlDataType);
        }
开发者ID:GoEddie,项目名称:DACExtensions,代码行数:25,代码来源:InMemoryTableBin2CollationRule.cs

示例11: AnalyzeColumns

        private static void AnalyzeColumns(
            SqlRuleExecutionContext context,
            TSqlObject index, 
            string defaultCollation,
            IList<SqlRuleProblem> problems)
        {
            foreach (TSqlObject column in index.GetReferenced(Index.Columns)
                                               .Where(column => IsCharacterColumn(column)))
            {
                // Fall back on the default project collation if none is defined for the specific column
                 string collation = column.GetProperty<string>(Column.Collation) ?? defaultCollation ?? string.Empty;
                if (!collation.EndsWith(Bin2Ending, StringComparison.OrdinalIgnoreCase))
                {
                    // Error looks liks "Index <name> on column <name> should have a BIN2 collation instead of <collation>"
                    // Choosing to add 1 problem per-column. This will cause more warnings in the error manager but is more precise
                    string errorMsg = string.Format(CultureInfo.CurrentCulture,
                        context.RuleDescriptor.DisplayDescription,
                        RuleUtils.GetElementName(index, context, ElementNameStyle.EscapedFullyQualifiedName),
                        RuleUtils.GetElementName(column, context, ElementNameStyle.EscapedFullyQualifiedName),
                        collation);

                    SqlRuleProblem problem = new SqlRuleProblem(errorMsg, index);
                    problems.Add(problem);
                }
            }
        }
开发者ID:GoEddie,项目名称:DACExtensions,代码行数:26,代码来源:InMemoryTableBin2CollationRule.cs


注:本文中的TSqlObject.GetReferenced方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。