score:15

Accepted answer
var result = tickets.GroupBy(t => t.EventName)
                    .Select(g  => new { 
                             EventName = g.Key, 
                             TicketCount = g.Sum(t => t.TicketCount), 
                             Price = g.Sum(t => t.Price)
                    });

foreach(var x in result)
     Console.WriteLine("EventName = {0}, TicketCount = {1}, Price = {2}"
                       , x.EventName , x.TicketCount , x.Price);

score:4

var groupedByEvent = tickets.GroupBy(t => t.EventName);

var obj = groupByEvent.Select(group => new {
   EventName = group._Key,
   TicketCount = group.Sum(x => x.TicketCount),
   Price = group.Sum(x => x.Price)
});

score:4

First you have to set your POCO class right:

public class Ticket
{
  public string EventName {get;set;}
  public string Count {get;set;}
  public int Price {get;set;}
  public int TicketCount { get; set; }
}

Price has to be and int and also like the TicketCount, that's necessarily for the sum.

Then the linq query will look like this:

var events = tickets.GroupBy(t => t.EventName).Select(g => new 
{
  EventName = g.Key,
  TicketCount = g.Sum(t => t.TicketCount),
  Price = g.Sum(t => t.Price)
});

Related Articles