Esempio n. 1
0
        static void Main(string[] args)
        {
            msdbEntities1 ctx = new msdbEntities1();

            ctx.Database.Log = Console.WriteLine;

            // Eager load - bring all from products and categories
            foreach (product p in ctx.products.Include("category"))
            {
                Console.WriteLine($"{p.ProdName}  - {p.category.CatDesc}");
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            msdbEntities1 ctx = new msdbEntities1();

            // ctx.Database.Log = Console.WriteLine;

            foreach (var cat in ctx.categories)
            {
                Console.WriteLine("****" + cat.CatDesc + "*******");
                // Get all products for category cat
                foreach (var p in cat.products)
                {
                    Console.WriteLine(p.ProdName);
                }
            }
        }