public IEnumerable <string> GetWords(Language language) { string connectionString = ConfigurationManager.AppSettings["connectionstring"]; string collectionName = MapLanguageToCollectionName(language); if (string.IsNullOrWhiteSpace(collectionName)) { return(Enumerable.Empty <string>()); } MongoCappedRepository <WordListByFirstLetter> repo = new MongoCappedRepository <WordListByFirstLetter>(connectionString, DatabaseName, collectionName, 26); var wordsByFirstLetter = repo.GetAll(); var words = wordsByFirstLetter.SelectMany(x => x.Words).Distinct().ToArray(); return(words); }
public void Fetch(Language language, IEnumerable <string> words) { string connectionString = ConfigurationManager.AppSettings["connectionstring"]; string collectionName = MapLanguageToCollectionName(language); if (string.IsNullOrWhiteSpace(collectionName)) { return; } MongoCappedRepository <WordListByFirstLetter> repo = new MongoCappedRepository <WordListByFirstLetter>(connectionString, DatabaseName, collectionName, 26); var frenchWordsByFirstLetter = words.Distinct().GroupBy(x => x[0]).Select(x => new WordListByFirstLetter { FirstLetter = x.Key, Words = x.ToList() }).ToList(); repo.Fetch(frenchWordsByFirstLetter); }