private List <EnumRecord> LoadEnumValues(IEnumerable <string> enumTableNames) { List <EnumRecord> values = new List <EnumRecord>(); foreach (string table in enumTableNames) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Working with table: {0}", table); Console.WriteLine(""); if (table.EndsWith("Enum")) { using (SqlConnection connection = new SqlConnection()) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName]; connection.ConnectionString = settings.ConnectionString; connection.Open(); StringBuilder cmd = new StringBuilder(); cmd.AppendFormat("SELECT * FROM {0}", table); SqlCommand cmdSelect = new SqlCommand(cmd.ToString(), connection); SqlDataReader myReader = cmdSelect.ExecuteReader(); if (myReader != null) { while (myReader.Read()) { var value = new EnumRecord() { Name = table, Lookup = (string)myReader["Lookup"], Description = (string)myReader["Description"], LongDescription = (string)myReader["LongDescription"] }; values.Add(value); } } } } } return(values); }
private List<EnumRecord> LoadEnumValues(IEnumerable<string> enumTableNames) { List<EnumRecord> values = new List<EnumRecord>(); foreach (string table in enumTableNames) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Working with table: {0}", table); Console.WriteLine(""); if (table.EndsWith("Enum")) { using (SqlConnection connection = new SqlConnection()) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName]; connection.ConnectionString = settings.ConnectionString; connection.Open(); StringBuilder cmd = new StringBuilder(); cmd.AppendFormat("SELECT * FROM {0}", table); SqlCommand cmdSelect = new SqlCommand(cmd.ToString(), connection); SqlDataReader myReader = cmdSelect.ExecuteReader(); if (myReader != null) while (myReader.Read()) { var value = new EnumRecord() { Name = table, Lookup = (string)myReader["Lookup"], Description = (string)myReader["Description"], LongDescription = (string)myReader["LongDescription"] }; values.Add(value); } } } } return values; }