public async Task <int> SumAsync(IEnumerable <KeyValuePair <Attribute, int> > rawAttributes, Attribute attribute) { var tmp = rawAttributes.GroupBy(x => x.Key); var ret = tmp.Where(x => x.Key == attribute).Select(x => x.Sum(y => y.Value)); return(await Task.FromResult(ret.FirstOrDefault()).ConfigureAwait(false)); }
public int Sum(IEnumerable <KeyValuePair <Attribute, int> > rawAttributes, Attribute attribute) => SumAsync(rawAttributes, attribute).Result;