コード例 #1
0
ファイル: Program.cs プロジェクト: anilsathe21/Training-1
        private static void ExplicitLoad()
        {
            using (var context = new AWEntities())
            {
                var customer = context.Customers.First();
                context.Entry(customer).Collection(c => c.SalesOrderHeaders).Load();

                Console.WriteLine("{0} : {1}", customer.AccountNumber, customer.SalesOrderHeaders.Count());
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: anilsathe21/Training-1
        private static void EagerLoad()
        {
            using (var context = new AWEntities())
            {
                // Include lambda extension method needs System.Data.Entity using statement
                var customersWithOrders = context.Customers.Include(c => c.SalesOrderHeaders).ToList();

                foreach (var customer in customersWithOrders)
                {
                    Console.WriteLine("{0} : {1}", customer.AccountNumber, customer.SalesOrderHeaders.Count());
                }
            }
        }