public DatabaseTableRowCounts Constructor(string tableName, long rowCount)
        {
            DatabaseTableRowCounts target = new DatabaseTableRowCounts(tableName, rowCount);

            return(target);
            // TODO: add assertions to method DatabaseTableRowCountsTest.Constructor(String, Int64)
        }
        public string SqlStatement()
        {
            string result = DatabaseTableRowCounts.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabaseTableRowCountsTest.SqlStatement()
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the table row counts.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>
        /// table row counts
        /// </returns>
        public List <DatabaseTableRowCounts> GetTableRowCounts(string database)
        {
            this.ExecuteUseDatabase(database);
            List <DatabaseTableRowCounts> results = new List <DatabaseTableRowCounts>();
            DatabaseTableRowCounts        resultrow;
            string sqlString = DatabaseTableRowCounts.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 DatabaseTableRowCounts(
                                reader.GetString(reader.GetOrdinal("Table")),
                                reader.GetInt64(reader.GetOrdinal("RowCount")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }