Example #1
0
        public string SqlStatement()
        {
            string result = DatabaseIdentityFields.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabaseIdentityFieldsTest.SqlStatement()
        }
Example #2
0
        public DatabaseIdentityFields Constructor(
            string schema,
            string tableName,
            string column,
            string type,
            int seed,
            int increment,
            int currentIdentity
            )
        {
            DatabaseIdentityFields target = new DatabaseIdentityFields
                                                (schema, tableName, column, type, seed, increment, currentIdentity);

            return(target);
            // TODO: add assertions to method DatabaseIdentityFieldsTest.Constructor(String, String, String, String, Int32, Int32, Int32)
        }
Example #3
0
        /// <summary>
        /// Gets the identity fields.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>the identity fields</returns>
        public List <DatabaseIdentityFields> GetIdentityFields(string database)
        {
            this.ExecuteUseDatabase(database);

            List <DatabaseIdentityFields> results = new List <DatabaseIdentityFields>();
            DatabaseIdentityFields        resultrow;
            string sqlString = DatabaseIdentityFields.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 DatabaseIdentityFields(
                                reader.GetString(reader.GetOrdinal("Schema")),
                                reader.GetString(reader.GetOrdinal("TableName")),
                                reader.GetString(reader.GetOrdinal("Column")),
                                reader.GetString(reader.GetOrdinal("Type")),
                                reader.GetInt32(reader.GetOrdinal("Seed")),
                                reader.GetInt32(reader.GetOrdinal("Increment")),
                                reader.GetInt32(reader.GetOrdinal("CurrentIdentity")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }