public static PoliticianOfficeStatus GetOfficeStatus(string politicianKey) { const string cmdText = "CALL OfficeStatus(@PoliticianKey)"; var cmd = VoteDb.GetCommand(cmdText, -1); VoteDb.AddCommandParameter(cmd, "PoliticianKey", politicianKey); var table = new DataTable(); using (var cn = VoteDb.GetOpenConnection()) { cmd.Connection = cn; var adapter = VoteDb.GetDataAdapter(cmd); adapter.Fill(table); } var status = table.Rows[0]["Status"].ToString(); PoliticianStatus policicianStatus; if (!Enum.TryParse(status, out policicianStatus)) { policicianStatus = PoliticianStatus.Unknown; } var result = new PoliticianOfficeStatus { OfficeKey = table.Rows[0]["OfficeKey"].ToString(), PoliticianStatus = policicianStatus }; return(result); }