I have the following array of TrackerReport Object:
public class TrackerReport : TrackerMilestone
{
public long Views { get; set; }
public override string ToString()
{
return "Id=" + MilestoneId + " | Name=" + Name + " | Views = " + Views;
}
I post also the parent class to better explain:
public class TrackerMilestone
{
public int MilestoneId { get; set; }
public int CampaignId { get; set; }
public string Name { get; set; }
public int? SortIndex { get; set; }
public string Url { get; set; }
public bool IsGoal { get; set; }
public bool IsPartialGoal { get; set; }
public int? ParentMilestoneId { get; set; }
public int? ViewPercent { get; set; }
public override string ToString()
{
return "Id=" + MilestoneId + " | Name=" + Name + " | Url = " + Url;
}
}
So that it is displayed like this more or less:
ID Name Url Counter
1 A ab.com 5
2 N ac.com 2
And I have a List of this object that I fill in this way:
var trackerReportList = new List<TrackerReport[]>();
foreach (var trackerItem in trackerChildren)
{
//currentReport is the array of TrackerReport TrackerReport[] above mentioned
var currentReport = GetReportForItem(GetFromDate(), GetToDate(), trackerItem.ID,
FindCampaignId(trackerItem));
trackerReportList.Add(currentReport);
}
All the entries have the same values, but the counter, so, for ex:
list1:
ID Name Url Counter
1 A ab.com 5
2 N ac.com 2
list2:
ID Name Url Counter
1 A ab.com 17
2 N ac.com 28
My goal is to generate a single TrackerReport[], with the sum of the counter values as counter.
TrackerReport[]:
ID Name Url Counter
1 A ab.com 22
2 N ac.com 30
Is there any Linq query to do this? Or If you come up with a better solution, just post it.
Thanks in advance!