public static int Next()
 {
     if (iterator == null)
     {
         iterator = new ContentIterator(list);
     }
     return(iterator.Next());
 }
        private int PracticeLocation(string zip, string countryCode)
        {
            if (countryCode != "US")
            {
                return(PracticeLocationOpenMaket.Next());
            }
            int zipCode = 0;

            if (!int.TryParse(zip, out zipCode))
            {
                throw new InvalidCastException();
            }

            if (practiceByZip.ContainsKey(zipCode))
            {
                return(practiceByZip[zipCode].Next());
            }

            var query = $"select PracticeLocationKey from provider.practiceLocation pl join provider.Address a on pl.address = a.Addresskey where a.ZipCode='{zipCode}'";
            var comnd = new SqlCommand(query, conn, transaction);

            using (var rs = comnd.ExecuteReader())
            {
                if (!rs.HasRows)
                {
                    return(PracticeLocationOpenMaket.Next());
                }

                List <int> keys = new List <int>();
                while (rs.Read())
                {
                    var key = (int)rs.GetSqlInt32(0);
                    keys.Add(key);
                }

                rs.Close();
                ContentIterator loc = new ContentIterator(keys);
                practiceByZip.Add(zipCode, loc);
                return(loc.Next());
            }
        }