using System.Collections.Generic;
public static void Main()
var items = new List<Item>
TransactionType = "Income"
TransactionType = "Income"
TransactionType = "Outgoing"
TransactionType = "Outgoing"
Totals result = new Totals
TotalIncoming = items.Where(x => x.TransactionType == "Income").Sum(x => x.TransactionValue),
TotalOutgoing = items.Where(x => x.TransactionType == "Outgoing").Sum(x => x.TransactionValue)
List<ItemTotals> query = items.GroupBy(x => x.TransactionType)
.Select(x => new ItemTotals
Total = x.Sum(z => z.TransactionValue)
Console.WriteLine("TotalIncoming : {0}", result.TotalIncoming);
Console.WriteLine("TotalOutgoing : {0}", result.TotalOutgoing);
foreach (var item in query)
Console.WriteLine("ItemType : {0}", item.ItemType);
Console.WriteLine("Total : {0}", item.Total);
public decimal TransactionValue { get; set; }
public string TransactionType { get; set; }
public decimal TotalIncoming { get; set; }
public decimal TotalOutgoing { get; set; }
public string ItemType { get; set; }
public decimal Total { get; set; }