Exemple #1
0
        public static void Main()
        {
            using (db = new NORTHWNDEntities())
            {
                var customers = db.Customers
                    .Join(db.Orders,
                        (c => c.CustomerID),
                        (o => o.CustomerID),
                        (c, o) => new
                        {
                            CustomerName = c.ContactName,
                            OrderYear = o.OrderDate.Value.Year,
                            o.ShipCountry
                        })
                    .ToList()
                    .FindAll(c => c.ShipCountry == "Canada" && c.OrderYear == 1997)
                    .ToList()
                    .OrderBy(c => c.CustomerName);

                foreach (var c in customers)
                {
                    Console.WriteLine(c.CustomerName + " : " + c.OrderYear + " : " + c.ShipCountry);
                }
            }
        }
Exemple #2
0
        public static void Main()
        {
            using (var ctx = new NORTHWNDEntities())
            {
                foreach (var customer in ctx.Customers.Where(x => x.Country == "UK"))
                {
                    Console.WriteLine(customer.ContactName + " : " + customer.CompanyName);
                }
                Console.WriteLine(new string('=', 40));

                var customers =
                    from c in ctx.Customers
                    where c.City == "Madrid"
                    select c;
                foreach (var c in customers)
                {
                    Console.WriteLine(c.ContactName);
                }
                Console.WriteLine(new string('=', 40));
            }
        }
Exemple #3
0
        public static void Main()
        {
            using (var ctx = new NORTHWNDEntities())
            {
                foreach (var customer in ctx.Customers.Where(x => x.Country == "UK"))
                {
                    Console.WriteLine(customer.ContactName + " : " + customer.CompanyName);
                }
                Console.WriteLine(new string('=',40));

                var customers =
                    from c in ctx.Customers
                    where c.City == "Madrid"
                    select c;
                foreach (var c in customers)
                {
                        Console.WriteLine(c.ContactName);
                }
                Console.WriteLine(new string('=', 40));
            }
        }