Exemple #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This loads information from a SQL index.</summary>
        ///
        /// <param name="sqlIndex">The input sql index.</param>
        ///--------------------------------------------------------------------------------
        public void LoadIndex(Index sqlIndex)
        {
            try
            {
                // load the basic index information
                SqlIndexName  = sqlIndex.Name;
                DbID          = sqlIndex.ID;
                IsClustered   = sqlIndex.IsClustered;
                IsUnique      = sqlIndex.IsUnique;
                IsXmlIndex    = sqlIndex.IsXmlIndex;
                IsFullTextKey = sqlIndex.IsFullTextKey;
                FileGroup     = sqlIndex.FileGroup;
                Urn           = sqlIndex.Urn;
                State         = sqlIndex.State.ToString();

                // load information for each property
                foreach (Microsoft.SqlServer.Management.Smo.Property loopProperty in sqlIndex.Properties)
                {
                    if (DebugHelper.DebugAction == DebugAction.Stop)
                    {
                        return;
                    }
                    if (loopProperty.Expensive == false && loopProperty.IsNull == false && !String.IsNullOrEmpty(loopProperty.Value.ToString()))
                    {
                        if (loopProperty.Name == "ID" || loopProperty.Name == "IgnoreDuplicateKeys" || loopProperty.Name == "IndexKeyType")
                        {
                            SqlProperty property = new SqlProperty();
                            property.SqlPropertyID = Guid.NewGuid();
                            property.SqlIndex      = this;
                            property.LoadProperty(loopProperty);
                            SqlPropertyList.Add(property);
                        }
                    }
                }

                // load information for each extended property
                //foreach (ExtendedProperty loopProperty in sqlIndex.ExtendedProperties)
                //{
                //    SqlExtendedProperty property = new SqlExtendedProperty();
                //    property.SqlExtendedPropertyID = Guid.NewGuid();
                //    property.SqlIndex = this;
                //    property.LoadExtendedProperty(loopProperty);
                //    SqlExtendedPropertyList.Add(property);
                //}

                // load information for each column
                foreach (IndexedColumn loopColumn in sqlIndex.IndexedColumns)
                {
                    if (DebugHelper.DebugAction == DebugAction.Stop)
                    {
                        return;
                    }
                    SqlIndexedColumn column = new SqlIndexedColumn();
                    column.SqlIndexedColumnID = Guid.NewGuid();
                    column.SqlIndex           = this;
                    column.LoadColumn(loopColumn);
                    SqlIndexedColumnList.Add(column);
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                bool reThrow = BusinessConfiguration.HandleException(ex);
                if (reThrow)
                {
                    throw;
                }
            }
        }
Exemple #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This loads information from a MySQL index.</summary>
        ///
        /// <param name="sqlConnection">The input sql connection</param>
        /// <param name="variables">Database level variables</param>
        /// <param name="index">The table row data</param>
        /// <param name="indexColumns">The index columns table data</param>
        ///--------------------------------------------------------------------------------
        public void LoadMySQLIndex(MySqlConnection sqlConnection, NameObjectCollection variables, DataRow index, DataTable indexColumns)
        {
            try
            {
                // load index information
                foreach (DataColumn column in index.Table.Columns)
                {
                    // load important properties into index, the rest as additional sql properties
                    switch (column.ColumnName)
                    {
                    case "INDEX_NAME":
                        SqlIndexName = index[column.ColumnName].GetString();
                        break;

                    case "PRIMARY":
                        IsClustered = index[column.ColumnName].GetBool();                                 // may not be a good setting
                        break;

                    case "UNIQUE":
                        IsUnique = index[column.ColumnName].GetBool();
                        break;

                    default:
                        SqlProperty property = new SqlProperty();
                        property.SqlPropertyID = Guid.NewGuid();
                        property.SqlIndex      = this;
                        property.LoadMySQLProperty(column.ColumnName, null, index[column.ColumnName].GetString());
                        SqlPropertyList.Add(property);
                        break;
                    }
                }

                // load information for each column
                if (indexColumns != null)
                {
                    foreach (DataRow row in indexColumns.Rows)
                    {
                        if (DebugHelper.DebugAction == DebugAction.Stop)
                        {
                            return;
                        }
                        if (row["TABLE_NAME"].GetString() == SqlTable.SqlTableName && row["INDEX_NAME"].GetString() == SqlIndexName)
                        {
                            SqlIndexedColumn column = new SqlIndexedColumn();
                            column.SqlIndexedColumnID = Guid.NewGuid();
                            column.SqlIndex           = this;
                            column.LoadMySQLColumn(sqlConnection, variables, row);
                            SqlIndexedColumnList.Add(column);
                        }
                    }
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                bool reThrow = BusinessConfiguration.HandleException(ex);
                if (reThrow)
                {
                    throw;
                }
            }
        }