Beispiel #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);
     }
 }
Beispiel #2
0
 public static void Scenariu4()
 {
     using (var context = new Scenariu4())
     {
         var business = new Business
         {
             Name          = "Corner Dry Cleaning",
             LicenseNumber = "100x1"
         };
         context.Businesses.Add(business);
         var retail = new Retail
         {
             Name          = "Shop and Save",
             LicenseNumber =
                 "200C",
             Address = "101 Main",
             City    = "Anytown",
             State   = "TX",
             ZIPCode = "76106"
         };
         context.Businesses.Add(retail);
         var web = new eCommerce
         {
             Name          = "BuyNow.com",
             LicenseNumber =
                 "300AB",
             URL = "www.buynow.com"
         };
         context.Businesses.Add(web);
         context.SaveChanges();
     }
     using (var context = new Scenariu4())
     {
         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);
         }
     }
 }
Beispiel #3
0
 public void Add()
 {
     using (var context = new BusinessContext())
     {
         var business = new Business {
             Name = "Corner Dry Cleaning", LicenseNumber = "100x1"
         };
         context.Businesses.Add(business);
         var retail = new Retail
         {
             Name  = "Shop and Save", LicenseNumber = "200C", Address = "101 Main", City = "Anytown",
             State = "TX", ZIPCode = "76106"
         };
         context.Businesses.Add(retail);
         var web = new eCommerce {
             Name = "BuyNow.com", LicenseNumber = "300AB", URL = "www.buynow.com"
         };
         context.Businesses.Add(web);
         context.SaveChanges();
     }
 }