private void GetMostCommonDomains() { var watch = System.Diagnostics.Stopwatch.StartNew(); List <KeyValuePair <string, int> > result = DataBaseInterface.GetMostCommonEmailAddress(); for (int i = 0; i < 0; i++) { result = DataBaseInterface.GetMostCommonEmailAddress(); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("Time it took databaserequest took : " + (elapsedMs)); Outputbox.Text += "most common email domains: \n"; for (int i = 0; i < Math.Min(_numberOfDomainsShown, result.Count); i++) { Outputbox.Text += result[i].Key + " amount: " + result[i].Value + "\n"; } }
private List <KeyValuePair <KeyValuePair <string, string>, int> > GetLargestCountys() { Dictionary <KeyValuePair <string, string>, int> countysCounter = new Dictionary <KeyValuePair <string, string>, int>(); List <KeyValuePair <string, string> > countys = DataBaseInterface.GetCountysWithPostcodes(); foreach (KeyValuePair <string, string> county in countys) { if (countysCounter.ContainsKey(county)) { countysCounter[county]++; } else { countysCounter.Add(county, 1); } } List <KeyValuePair <KeyValuePair <string, string>, int> > countysCounterResult = countysCounter.ToList(); return(countysCounterResult.AsParallel().OrderByDescending(x => x.Value).ToList()); }