Exemple #1
0
 private void InsertData4()
 {
     using (var context = new ModelBusiness())
     {
         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();
     }
 }
Exemple #2
0
 private void PrintData4()
 {
     using (var context = new ModelBusiness())
     {
         var data = String.Format("\n--- All Businesses ---\n");
         Console.WriteLine("\n--- All Businesses ---\n");
         textBox1.Text += data;
         foreach (var b in context.Businesses)
         {
             data = String.Format("{0} (#{1})", b.Name, b.LicenseNumber);
             Console.WriteLine("{0} (#{1})", b.Name, b.LicenseNumber);
             textBox1.Text += data;
         }
         Console.WriteLine("\n--- Retail Businesses ---");
         textBox1.Text += "\n--- Retail Businesses ---";
         foreach (var r in context.Businesses.OfType <Retail>())
         {
             data           = String.Format("{0} (#{1})", r.Name, r.LicenseNumber);
             textBox1.Text += data;
             Console.WriteLine("{0} (#{1})", r.Name, r.LicenseNumber);
             data           = String.Format("{0}", r.Address);
             textBox1.Text += data;
             Console.WriteLine("{0}", r.Address);
             data           = String.Format("{0}, {1} {2}", r.City, r.State, r.ZIPCode);
             textBox1.Text += data;
             Console.WriteLine("{0}, {1} {2}", r.City, r.State, r.ZIPCode);
         }
         textBox1.Text += "\n--- eCommerce Businesses ---";
         Console.WriteLine("\n--- eCommerce Businesses ---");
         foreach (var e in context.Businesses.OfType <eCommerce>())
         {
             data           = String.Format("{0} (#{1})", e.Name, e.LicenseNumber);
             textBox1.Text += data;
             Console.WriteLine("{0} (#{1})", e.Name, e.LicenseNumber);
             data           = String.Format("Online address is: {0}", e.URL);
             textBox1.Text += data;
             Console.WriteLine("Online address is: {0}", e.URL);
         }
     }
 }