Beispiel #1
0
 static void Main(string[] args)
 {
     //Performance();
     try
     {
         using (var context = new InheritanceContext())
         {
             context.Database.Initialize(true);
             context.Database.Log = Console.WriteLine;
             IQueryable <Payment> payments = from p in context.Payments select p;
             foreach (var payment in payments)
             {
                 Console.WriteLine(payment.ToString());
             }
             IQueryable <CreditCardPayment> creditCards = from p in context.Payments.OfType <CreditCardPayment>()
                                                          select p;
             foreach (var creditCard in creditCards)
             {
                 Console.WriteLine(creditCard.ToString());
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     Console.ReadLine();
 }
Beispiel #2
0
        private static void TPT()
        {
            using (var context = new InheritanceContext())
            {
                var pkw = new PKW {
                    Geschwindigkeit = 50, Sitzplätze = 5
                };
                var lkw = new LKW {
                    Geschwindigkeit = 30, MaxLadung = 18000
                };

                context.Fahrzeuge.Add(pkw);
                context.Fahrzeuge.Add(lkw);

                context.SaveChanges();
            }
        }
Beispiel #3
0
        private static void TPH()
        {
            using (var context = new InheritanceContext())
            {
                var c = new Customer {
                    Name = "Sepp", ShippingAddress = "München"
                };
                var e = new Employee {
                    Name = "Luis", Salary = 25000
                };

                context.People.Add(c);
                context.People.Add(e);

                context.SaveChanges();
            }
        }
Beispiel #4
0
        private static void TPC()
        {
            using (var context = new InheritanceContext())
            {
                var tisch = new Tisch {
                    Id = Guid.NewGuid(), Material = "Holz", AnzahlBeine = 7
                };
                var uhr = new Uhr {
                    Id = Guid.NewGuid(), Material = "Plastik", Zeit = DateTime.Now
                };

                context.Products.Add(tisch);
                context.Products.Add(uhr);

                context.SaveChanges();
            }
        }