I have a List with Objects that looks like this:
ID | ProjectID | ProjectTime | more....
And I'm trying to get a Distinct list of ProjectID
with the Sum of ProjectTime
.
The problem is the ProjectTime is a String in this format HH:mm ex: 06:30
.
With LINQ I can group the List with GroupBy
but the Sum function of LINQ doesn't accept String.
I can't change the Type of ProjectTime!
var overviewList = tmpList.GroupBy(x => x.ProjectID)
.Select(x => new
{
ProjectID = x.Key,
ProjectTime = x.Sum(o => int.Parse(o.ProjectTime)) //Wrong
});