Exemplo n.º 1
0
 private static void TestBusiness()
 {
     using var context = new BusinessContext();
     context.Businesses.Add(Business.Create("Corner Dry Cleaning", "100x1"));
     context.Businesses.Add(Retail.Create("Shop and Save", "200C", "101 Main", "Anytown", "TX", "76106"));
     context.Businesses.Add(ECommerce.Create("BuyNow.com", "300AB", "www.buynow.com"));
     context.SaveChanges();
     Console.WriteLine("\n--- All Businesses ---");
     foreach (var b in context.Businesses)
     {
         Console.WriteLine("{0} (#{1})", b.Name, b.LicenseNumber);
     }
     Console.WriteLine("\n--- Retail Businesses ---");
     foreach (var r in context.Businesses.OfType <Retail>())
     {
         Console.WriteLine("{0} (#{1})", r.Name, r.LicenseNumber);
         Console.WriteLine("{0}", r.Address);
         Console.WriteLine("{0}, {1} {2}", r.City, r.State, r.ZIPCode);
     }
     Console.WriteLine("\n--- eCommerce Businesses ---");
     foreach (var e in context.Businesses.OfType <ECommerce>())
     {
         Console.WriteLine("{0} (#{1})", e.Name, e.LicenseNumber);
         Console.WriteLine("Online address is: {0}", e.URL);
     }
 }