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


C# Column.Alter方法代码示例

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


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

示例1: RestoreNullCondition

        private static List<DroppedDependencyDbo> RestoreNullCondition(
            Table aTable, Column column, bool disableDependencies, Database db)
        {
            var rzlt = new List<DroppedDependencyDbo>();
            IndexKeyType oldIndexKeyType;
            bool oldIsClustered;
            string oldIndexName;

            for (int i = aTable.Indexes.Count - 1; i >= 0; i--)
            {
                Index currentInd = aTable.Indexes[i];
                string[] indexColumns = GetIndexColumns(currentInd);
                if (indexColumns.Contains(column.Name))
                {
                    if (disableDependencies)
                        DropDependentForeignKeys(currentInd.Name, db, rzlt);

                    oldIndexName = currentInd.Name;
                    oldIndexKeyType = currentInd.IndexKeyType;
                    oldIsClustered = currentInd.IsClustered;
                    currentInd.Drop();

                    column.Nullable = true;
                    column.Alter();
                    CreateNewPrimaryKey(aTable, oldIndexName, oldIndexKeyType, indexColumns);
                    return rzlt;
                }
            }

            // No index contains column
            column.Nullable = true;
            column.Alter();
            return rzlt;
        }
开发者ID:kimanidev,项目名称:CFCDatabase,代码行数:34,代码来源:CfcWebService_Utilities_1.cs

示例2: SetPropertyValue

 /// <summary>
 /// Establish the extended property and associated value
 /// </summary>
 /// <param name="table">table to be updated</param>
 /// <param name="databasePropertyName">extended property</param>
 /// <param name="value">value</param>
 /// <param name="column">column</param>
 /// <param name="overwrite">overwrite</param>
 private void SetPropertyValue(Table table, string databasePropertyName, string value, Column column, bool overwrite)
 {
     if (!column.ExtendedProperties.Contains(databasePropertyName))
     {
         column.ExtendedProperties.Add(new ExtendedProperty(column, databasePropertyName, value));
     }
     else
     {
         if (overwrite || string.IsNullOrEmpty(column.ExtendedProperties[databasePropertyName].Value.ToString()))
         {
             column.ExtendedProperties[databasePropertyName].Value = value;
             column.ExtendedProperties[databasePropertyName].Alter();
         }
     }
     column.Alter();
 }
开发者ID:wendy321,项目名称:DataDictionaryCreator,代码行数:24,代码来源:MainForm.cs

示例3: RemoveNullCondition

        /// <summary>
        /// Removes is null condition from the column
        /// </summary>
        /// <param name="aTable">Table, <see cref="Table"/></param>
        /// <param name="currentColumn">Column, <see cref="Column"/></param>
        private static void RemoveNullCondition(Table aTable, Column currentColumn)
        {
            const string query = "SELECT count(1) AS NullCounter FROM [{0}] WHERE [{1}] IS NULL";
            string sql = String.Format(query, aTable.Name, currentColumn.Name);
            int nullCounter;

            using (var connection = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(sql, connection);
                connection.Open();
                nullCounter = (Int32)cmd.ExecuteScalar();
                connection.Close();
            }
            if (nullCounter > 0)
                throw new Exception(String.Format("Table {0} contains NULLs in the {1} column.", aTable.Name, currentColumn.Name));

            currentColumn.Nullable = false;
            currentColumn.Alter();
        }
开发者ID:kimanidev,项目名称:CFCDatabase,代码行数:24,代码来源:CfcWebService_Utilities_1.cs


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