模型是:
public class Word
{
public int Id { get; set; }
public IList<UsedCount> UsedCount { get; set; }
}
public class UsedCount
{
public int Id { get; set; }
public string Key { get; set; }
public int Value { get; set; }
}
有语言列表:
// Actually there are more then 3 langs used
List<string> langList = new List<string> { "en", "pl", "de" };
还有单词表
List<Word> words = new List<Words>();
我计算每个单词在每种语言中使用的次数。
我需要让所有的单词总共使用100次以上,不管使用哪种语言:
renewingIteration = Words.Where(p => (
p.UsedCount.FirstOrDefault(count => count.Key == langList[0]).Value +
p.UsedCount.FirstOrDefault(count => count.Key == langList[1]).Value +
p.UsedCount.FirstOrDefault(count => count.Key == langList[2]).Value
//... and so on
> 100)
如何使其更简单并避免编写langlist[0]、langlist[1]…手动?