Beispiel #1
0
        /// <summary>
        /// 点标记
        /// </summary>
        public void Show()
        {
            var list      = new ProductList();
            var products  = list.GetProductList();
            var customers = list.GetCustomerList();

            var productFirstChars =
                from p in products
                select p.ProductName[0];
            var customerFirstChars =
                from c in customers
                select c.CompanyName[0];

            Console.WriteLine();
            Console.WriteLine("Intersect_2 点标记");
            //Numbers < 5:
            var result = productFirstChars.Intersect(customerFirstChars).OrderBy(x => x);

            Print(result);
        }
Beispiel #2
0
        /// <summary>
        /// 查询表达式
        /// </summary>
        /// <param name="x"></param>
        public void Show(int x)
        {
            var list      = new ProductList();
            var customers = list.GetCustomerList();

            Console.WriteLine();
            Console.WriteLine("GroupBy_Nested 查询表达式");
            //n % 5
            var result = (from w in customers
                          select new {
                w.CompanyName, YearGroups = from o in w.Orders
                                            group o by o.OrderDate.Year into yg
                                            select new {
                    Year = yg.Key,
                    MonthGroups = from o in yg
                                  group o by o.OrderDate.Month into mg
                                  select new { Month = mg.Key, Orders = mg }
                }
            }).ToList();

            Print(result);
        }