+3  A: 
var yearsList = from e in Events
                group e by e.EventDate.Year into g
                select new { Year = g.Key, Events = g };

That will get you a list of objects with a "Year" property and an "Events" property (all the events for that year).

Have a look at this handy reference: 101 Linq Samples.

Matt Hamilton
Thanks! Pretty simple.
orandov
+4  A: 

You're really looking for an ordered group.

var yearsList = from e in Events
                group e by e.EventDate.Year into g
                orderby g.Key
                select g;

foreach(var yearGroup in yearsList)
{
    int year = yearGroup.Key;
    foreach(Event e in yearGroup)
    {
        // do something with the events
    }
}
Jacob Proffitt
Thanks for the answer.
orandov
+1  A: 

Assuming you have the following Event class

 public class Event
    {
            public int Year { get; set; }
            public string Name { get; set; }
            public static Event[] GetEvents()
            {
                return new Event[]        
                {
                new Event{ Name="Event1", Year=2001},
                new Event{ Name="Event2", Year=2002},
                new Event{ Name="Event3", Year=2003},

                new Event{ Name="Event4", Year=2001},
                new Event{ Name="Event5", Year=2002},
                new Event{ Name="Event6", Year=2003},

                new Event{ Name="Event7", Year=2001},
                new Event{ Name="Event8", Year=2002},
                new Event{ Name="Event9", Year=2003}
            };

        }
 }

 public class Program
  {
      static void Main(string[] args)
        {

            var groupedEvents = Event.GetEvents().GroupBy(e => e.Year);

            foreach (var groupedEvent in groupedEvents)
            {
                Console.WriteLine("Year:{0}",groupedEvent.Key);
                foreach (var evnt in groupedEvent)
                {
                    Console.WriteLine("---- Event Name:{0}",evnt.Name);
                }
        }


   }
}

The above should give you events grouped by year

Abhijeet Patel