using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EnchainementLINQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };
            IEnumerable<string> filtered = names.Where(n => n.Contains("a"));
            IEnumerable<string> sorted = filtered.OrderBy(n => n.Length);
            IEnumerable<string> finalQuery = sorted.Select(n => n.ToUpper());
            foreach (string name in finalQuery)
                Console.WriteLine(name);

            IEnumerable<string> query = names
                                            .Where(n => n.Contains("a"))
                                            .OrderBy(n => n.Length)
                                            .Select(n => n.ToUpper());
            foreach (string name in query)
                Console.WriteLine(name);

            IEnumerable<string> querySyntax =   from n in names
                                                where n.Contains("a")
                                                orderby (n.Length)
                                                select (n.ToUpper());
            foreach (string name in querySyntax)
                Console.WriteLine(name);


            Console.ReadKey();
        }
    }
}
