public static string GetPoliticianListForOfficeInElection(string electionKey, string officeKey, int commandTimeout = -1) { var nameList = GetPoliticiansForOfficeInElection(electionKey, officeKey, commandTimeout).Rows.OfType <DataRow>() .Select(row => Politicians.FormatName(row)) .ToList(); return(nameList.JoinText()); }
public static IEnumerable <string> GetIncumbentsByState(string stateCode, int commandTimeout = -1) { const string cmdText = "SELECT PoliticianKey,RunningMateKey FROM OfficesOfficials" + " WHERE StateCode IN (@StateCode,'') AND" + " CountyCode='' AND LocalKey=''"; var cmd = VoteDb.GetCommand(cmdText, commandTimeout); var table = new DataTable(); using (var cn = VoteDb.GetOpenConnection()) { cmd.Connection = cn; VoteDb.AddCommandParameter(cmd, "StateCode", stateCode); DbDataAdapter adapter = new MySqlDataAdapter(cmd as MySqlCommand); adapter.Fill(table); } return(table.Rows.Cast <DataRow>().Select(row => row.PoliticianKey()) .Union(table.Rows.Cast <DataRow>().Select(row => row.RunningMateKey())) .Where(k => stateCode.IsEqIgnoreCase(Politicians.GetStateCodeFromKey(k)))); }