>1 10 >2 2 >2 55 >1 20 >1 30 >3 10 >1 20 >>I need to convert that to:
>1 80 >2 57 >3 10 ></code> >it must be the sum of the second column grouped by column 1. >I already have a linq to get an unsorted list of the 2 colums: ><code> >var transact= from data in result >select new {Name=data.uId, Total=(int)data.Total}; >>With this I have the first list, now I need to store by uId and sum the Total, any ideas? I have tried with no success List List int, Keyvaluepair and I really don't understand what to do. I need to iterate the list after the linq, adding uid and sum second column each time the uid repeats.
>var acu=new List<KeyValuePair<int, int>>(); >foreach (var item in transact){ >//here is it good to find the key here and update total? or use another kind of structure or dictionary? > acu.Add(new KeyValuePair<int, int>(item.uId, item.Total)); >} >>