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


C# DatabaseTable.FindColumn方法代码示例

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


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

示例1: ForeignKeyCollectionName

        /// <summary>
        /// Returns the name of an inverse foreign key property. Uses <see cref="NameCollection"/>
        /// For single fks, it's a collection using the name of the fk table.
        /// For multiple fks, it's a collection using the name of the fk columns
        /// </summary>
        /// <param name="targetTable">The target table.</param>
        /// <param name="table">The table.</param>
        /// <param name="foreignKey">The foreign key.</param>
        /// <returns>
        /// Eg OrderLine has fk to Order. Order will have an ICollection&lt;OrderLine&gt; called "OrderLineCollection".
        /// Multiple fk eg Order has Delivery Address and Billing Address. 
        /// Address will have an ICollection&lt;Order&gt; called "DeliveryAddressCollection", 
        /// and another ICollection&lt;Order&gt; called "BillingAddressCollection"
        /// </returns>
        public virtual string ForeignKeyCollectionName(string targetTable, DatabaseTable table, DatabaseConstraint foreignKey)
        {
            var fksToTarget = table.ForeignKeys.Where(x => x.RefersToTable == targetTable).ToList();
            string name = table.NetName;
            if (fksToTarget.Count > 1)
                name = string.Join("", foreignKey.Columns.Select(x => table.FindColumn(x).NetName).ToArray());

            return NameCollection(name);
        }
开发者ID:faddiv,项目名称:dbschemareader,代码行数:23,代码来源:Namer.cs

示例2: AddDescriptions

 public void AddDescriptions(DatabaseTable table)
 {
     var find = _list.FirstOrDefault(t => t.SchemaOwner == table.SchemaOwner && t.Name == table.Name);
     if (find == null) return;
     foreach (var col in find.Columns)
     {
         var match = table.FindColumn(col.Name);
         if (match != null) match.Description = col.Description;
     }
 }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:10,代码来源:ColumnDescriptionConverter.cs

示例3: MarkIndexedColumns

 private static void MarkIndexedColumns(DatabaseTable table, IEnumerable<DatabaseIndex> indexes)
 {
     foreach (var index in indexes)
     {
         foreach (var column in index.Columns)
         {
             var tableColumn = table.FindColumn(column.Name);
             if (tableColumn != null) tableColumn.IsIndexed = true;
         }
     }
 }
开发者ID:roadrunner75,项目名称:dbschemareader,代码行数:11,代码来源:IndexLoader.cs

示例4: AddComputed

 public static void AddComputed(DataTable dt, DatabaseTable table)
 {
     foreach (DataRow row in dt.Rows)
     {
         var tableName = row["TABLENAME"].ToString();
         if (!tableName.Equals(table.Name, StringComparison.OrdinalIgnoreCase))
             continue;
         var colName = row["COLUMNNAME"].ToString();
         var col = table.FindColumn(colName);
         if (col != null)
         {
             col.ComputedDefinition = row["COMPUTEDDEFINITION"].ToString();
             //remove the default value - it's readonly!
             col.DefaultValue = null;
         }
     }
 }
开发者ID:roadrunner75,项目名称:dbschemareader,代码行数:17,代码来源:SchemaConstraintConverter.cs

示例5: ForeignKeyName

        /// <summary>
        /// Returns the name of a foreign key property for a given foreign key.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="foreignKey">The foreign key.</param>
        /// <returns></returns>
        /// <remarks>
        /// If it is a simple foreign key, it is the NetName of the column
        /// if it is a composite foreign key, it is the NetName of the foreign table
        /// if there is a collision with the class name, append "Key"
        /// If there are multiple foreign keys to one table, ensure they are unique.
        /// </remarks>
        public virtual string ForeignKeyName(DatabaseTable table, DatabaseConstraint foreignKey)
        {
            var refTable = foreignKey.ReferencedTable(table.DatabaseSchema);

            if (refTable == null)
            {
                //we can't find the foreign key table, so just write the columns
                return null;
            }
            //This is a name for the foreign key. Only used for composite keys.
            var propertyName = refTable.NetName;

            //if there is only one column (not composite) use the netName of that column
            if (foreignKey.Columns.Count == 1)
            {
                var columnName = foreignKey.Columns.Single();
                var column = table.FindColumn(columnName);
                //if it is a primary key, we've used the original name for a scalar property
                if (!column.IsPrimaryKey)
                    propertyName = column.NetName;
            }
            else //composite keys
            {
                // Check whether the referenced table is used in any other key. This ensures that the property names
                // are unique.
                if (table.ForeignKeys.Count(x => x.RefersToTable == foreignKey.RefersToTable) > 1)
                {
                    // Append the key name to the property name. In the event of multiple foreign keys to the same table
                    // This will give the consumer context.
                    propertyName += foreignKey.Name;
                }
            }

            // Ensures that property name cannot be the same as class name
            if (propertyName == table.NetName)
            {
                propertyName += "Key";
            }
            return propertyName;
        }
开发者ID:faddiv,项目名称:dbschemareader,代码行数:52,代码来源:Namer.cs

示例6: AddIdentity

 /// <summary>
 /// Converts the "IdentityColumns" DataTable by updating the Identity column in a table
 /// </summary>
 public static void AddIdentity(DataTable dt, DatabaseTable table)
 {
     bool hasSeedInfo = dt.Columns.Contains("IdentitySeed");
     bool hasIncrementInfo = dt.Columns.Contains("IdentityIncrement");
     bool hasIdentityOptions = dt.Columns.Contains("IDENTITY_OPTIONS");
     bool hasGeneratedType = dt.Columns.Contains("GENERATION_TYPE");
     foreach (DataRow row in dt.Rows)
     {
         string tableName = row["TableName"].ToString();
         if (!tableName.Equals(table.Name, StringComparison.OrdinalIgnoreCase))
             continue;
         string colName = row["ColumnName"].ToString();
         var col = table.FindColumn(colName);
         if (col != null)
         {
             col.IsAutoNumber = true;
             col.IdentityDefinition = new DatabaseColumnIdentity();
             if (hasSeedInfo)
                 col.IdentityDefinition.IdentitySeed = long.Parse(row["IdentitySeed"].ToString());
             if (hasIncrementInfo)
                 col.IdentityDefinition.IdentityIncrement = long.Parse(row["IdentityIncrement"].ToString());
             if (hasIdentityOptions)
             {
                 var options = row["IDENTITY_OPTIONS"].ToString();
                 ParseIdentityOptions(col.IdentityDefinition, options);
             }
             if (hasGeneratedType)
             {
                 if (string.Equals(row["GENERATION_TYPE"].ToString(), "BY DEFAULT",
                     StringComparison.OrdinalIgnoreCase))
                 {
                     col.IdentityDefinition.IdentityByDefault = true;
                 }
             }
             //col.IsPrimaryKey = true;
         }
     }
 }
开发者ID:roadrunner75,项目名称:dbschemareader,代码行数:41,代码来源:SchemaConstraintConverter.cs

示例7: IsSharedPrimaryKey

 /// <summary>
 /// Determines whether two tables are related one to one (shared primary keys)
 /// </summary>
 /// <param name="destination">The destination table (principal).</param>
 /// <param name="origin">The origin table (dependent, has foreign key relationship to principal).</param>
 /// <returns>
 ///   <c>true</c> if this table's primary key is also a foreign key; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsSharedPrimaryKey(this DatabaseTable destination, DatabaseTable origin)
 {
     if (origin == null || destination == null) return false;
     var pk = origin.PrimaryKey;
     if (pk == null) return false;
     var columns = pk.Columns.Select(x => origin.FindColumn(x));
     //the primary key of the origin is also a foreign key to this table
     var allFk = columns.All(c => c.ForeignKeyTableName == destination.Name);
     return allFk;
 }
开发者ID:roadrunner75,项目名称:dbschemareader,代码行数:18,代码来源:DatabaseSchemaExtensions.cs


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