Example #1
0
        static void IndexFiltering()
        {
            var query = MusicFestival.GetMusicians().Where((m, index) => m.Name.StartsWith("N") && index > 5);

            foreach (var m in query)
            {
                Console.WriteLine("{0}\n", m.Name);
            }
        }
Example #2
0
        static void GetAliveMusiciansNames()
        {
            Console.WriteLine("This is GetAliveGroups...\n");
            var query = from m in MusicFestival.GetMusicians()
                        where m.IsDead == false
                        select m;

            foreach (var m in query)
            {
                Console.WriteLine("{0}\n", m.Name);
            }
        }
Example #3
0
        static void GetDeadMusicGroups()
        {
            Console.WriteLine("This is GetDeadMusicGroups...\n");
            var query = from m in MusicFestival.GetMusicians()
                        where m.PeopleCount > 1 && m.IsDead
                        select m;

            foreach (var m in query)
            {
                Console.WriteLine(m.ToString("All"));
            }
        }
Example #4
0
        static void AllDeadMusicians()
        {
            Console.WriteLine("\nAll dead musicians:\n");
            var query = from m in MusicFestival.GetMusicians()
                        where m.IsDead == true
                        orderby m.Id descending
                        select m.Name;

            foreach (var m in query)
            {
                Console.WriteLine(m);
            }
        }
Example #5
0
        static void VeryHollowQuery()
        {
            Console.WriteLine("\nVery Strange Query:\n");
            var query = from m1 in
                        (from m1 in MusicFestival.GetMusicians()
                         where m1.Birthyear >= 2010
                         select new { m1.Name, m1.PeopleCount })
                        join m2 in
                        (from m2 in MusicFestival.GetMusicians()
                         where m2.Birthyear < 2010 && m2.IsDead
                         select new { m2.Name, m2.PeopleCount }) on m1.PeopleCount equals m2.PeopleCount
                        select new { m1.Name, m2.PeopleCount };

            foreach (var m in query)
            {
                Console.WriteLine("Name:{0}\tPeople Count:{1}", m.Name, m.PeopleCount);
            }
        }