Пример #1
0
        public string SqlStatement()
        {
            string result = DatabaseNonClusteredIndexes.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabaseNonClusteredIndexesTest.SqlStatement()
        }
Пример #2
0
        /// <summary>
        /// Gets the database non clustered indexes.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>the database non clustered indexes</returns>
        public List <DatabaseNonClusteredIndexes> GetDatabaseNonClusteredIndexes(string database)
        {
            this.ExecuteUseDatabase(database);

            List <DatabaseNonClusteredIndexes> results = new List <DatabaseNonClusteredIndexes>();
            DatabaseNonClusteredIndexes        resultrow;
            string sqlString = DatabaseNonClusteredIndexes.SqlStatement();

            sqlString = string.Format("EXEC sp_executesql @statement = N'{0}'", sqlString.Replace("'", "''"));

            using (SqlConnection connection = new SqlConnection(this.ConnectionString))
                using (SqlCommand command = new SqlCommand(sqlString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            resultrow = new DatabaseNonClusteredIndexes(
                                reader.GetString(reader.GetOrdinal("Schema")),
                                reader.GetString(reader.GetOrdinal("Table")),
                                reader.GetString(reader.GetOrdinal("Index")),
                                reader.GetString(reader.GetOrdinal("Column")),
                                reader.GetString(reader.GetOrdinal("IsUnique")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }
Пример #3
0
        public DatabaseNonClusteredIndexes Constructor(
            string schema,
            string table,
            string index,
            string column,
            string unique
            )
        {
            DatabaseNonClusteredIndexes target
                = new DatabaseNonClusteredIndexes(schema, table, index, column, unique);

            return(target);
            // TODO: add assertions to method DatabaseNonClusteredIndexesTest.Constructor(String, String, String, String, String)
        }