示例#1
0
        public static void WorkMoreThan9EmployeeLinqQuery()
        {
            var mt9e = from s in shops
                       where s.Emp_Number > 9
                       select new { s.Name, s.Emp_Number };

            Shops.ToConsole(mt9e, "Work than 9 employee");
        }
示例#2
0
        public static void ContainStreetInAddressLinqQuery()
        {
            var street = from s in shops
                         where s.Address.Contains("utca")
                         select new { s.Name, s.Address };

            Shops.ToConsole(street, "Contain Street word");
        }
示例#3
0
        public static void ShopNameStartWithTLetterLinqQuery()
        {
            var startwith = from s in shops
                            where s.Name.StartsWith("O")
                            select new { s.Name };

            Shops.ToConsole(startwith, "Shop name start with 'T' letter");
        }
示例#4
0
        public static void ShortShopNameLinqQuery()
        {
            //var min = shops.Min(x => x.Name.Length);

            var shortname = from s in shops
                            let min = shops.Min(x => x.Name.Length)
                                      where s.Name.Equals(min)
                                      select new { s.Name };

            Shops.ToConsole(shortname, "Short shop name is");
        }
示例#5
0
        public static void ContainStreetInAddressLambdaEXP()
        {
            var street = shops.Where(x => x.Address.Contains("utca"))
                         .Select(x => new
            {
                x.Name,
                x.Phone
            });

            Shops.ToConsole(street, "Contain Street word");
        }
示例#6
0
        public static void WorkMoreThan9EmployeeLambdaEXP()
        {
            var mt9e = shops.Where(x => x.Emp_Number > 9)
                       .Select(x => new
            {
                x.Name,
                x.Address,
                x.Emp_Number
            });

            Shops.ToConsole(mt9e, "Work than 9 employee");
        }
示例#7
0
        public static void ShopNameStartWithTLetterLambdaEXP()
        {
            var startwith = shops.Where(x => x.Name.StartsWith("T"))
                            .Select(x => new
            {
                x.Name,
                x.Phone,
                x.IsToiletPaper
            });

            Shops.ToConsole(startwith, "Shop name start with 'T' letter");
        }
示例#8
0
        public static void ShortShopNameLambdaEXP()
        {
            var min = shops.Min(x => x.Name.Length);
            var max = shops.Max(x => x.Name.Length);

            Console.WriteLine("MIN = " + min);
            Console.WriteLine("MAX = " + max);

            //var shortname = shops.Where(x => x.Name.Length == min)
            var shortname = shops.Where(x => x.Name.Length == shops.Min(y => y.Name.Length))
                            .Select(x => x);

            Shops.ToConsole(shortname, "Short shop name is");
        }