예제 #1
0
        public string SqlStatement()
        {
            string result = DatabasePrimaryKeys.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabasePrimaryKeysTest.SqlStatement()
        }
예제 #2
0
        /// <summary>
        /// Gets the database primary keys.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>the database primary keys</returns>
        public List <DatabasePrimaryKeys> GetDatabasePrimaryKeys(string database)
        {
            this.ExecuteUseDatabase(database);

            List <DatabasePrimaryKeys> results = new List <DatabasePrimaryKeys>();
            DatabasePrimaryKeys        resultrow;
            string sqlString = DatabasePrimaryKeys.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 DatabasePrimaryKeys(
                                reader.GetString(reader.GetOrdinal("Schema")),
                                reader.GetString(reader.GetOrdinal("Table")),
                                reader.GetString(reader.GetOrdinal("Column")),
                                reader.GetString(reader.GetOrdinal("PrimaryKey")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }
예제 #3
0
        public DatabasePrimaryKeys Constructor(
            string schema,
            string table,
            string column,
            string primaryKey
            )
        {
            DatabasePrimaryKeys target
                = new DatabasePrimaryKeys(schema, table, column, primaryKey);

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