static FlightManager()
        {
            using (FlugDbContext ctx = new FlugDbContext())
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
                 
                if (!ctx.Flights.Any()) {

                    var f1 = new Flight { From = "Graz", To = "Hamburg", Date = DateTime.Now };
                    var f2 = new Flight { From = "Vienna", To = "London",  Date = DateTime.Now.AddHours(1) };
                    var f3 = new Flight { From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(2) };
                    var f4 = new Flight { From = "Hamburg", To = "Graz", Date = DateTime.Now.AddHours(3) };
                    var f5 = new Flight { From = "Vienna", To = "London", Date = DateTime.Now.AddHours(4) };
                    var f6 = new Flight { From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(5) };
                    var f7 = new Flight { From = "Vienna", To = "London",  Date = DateTime.Now.AddHours(6) };

                    var b1 = new Booking { PassengerId = 4711, Price = 300 };
                    f1.Bookings.Add(b1);

                    ctx.Flights.AddRange(f1, f2, f3, f4, f5, f6, f7);
                    ctx.SaveChanges();
                }
            }
        }
 public void Create(Flight flight) {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Add(flight);
         ctx.SaveChanges();
     }
 }
 public void Update(Flug flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Fluege.Update(flight);
         ctx.SaveChanges();
     }
 }
示例#4
0
 public void Create(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Add(flight);
         ctx.SaveChanges();
     }
 }
示例#5
0
 public void Delete(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Remove(flight);
         ctx.SaveChanges();
     }
 }
 public void Update(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Update(flight);
         //ctx.Entry(flight).Property("PlaneType").CurrentValue = "Boeing";
         ctx.SaveChanges();
     }
 }
示例#7
0
 public void Update(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Update(flight);
         //ctx.Entry(flight).Property("PlaneType").CurrentValue = "Boeing";
         ctx.SaveChanges();
     }
 }
示例#8
0
 public void Merge(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.ChangeTracker.TrackGraph(flight, (node) => {
             node.Entry.State = EntityState.Modified;
         });
         ctx.SaveChanges();
     }
 }
        static FlugManager()
        {
            using (FlugDbContext ctx = new FlugDbContext())
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();

                if (!ctx.Fluege.Any())
                {
                    var f1 = new Flug {
                        Abflugort = "Graz", Zielort = "Hamburg", Datum = DateTime.Now
                    };
                    var f2 = new Flug {
                        Abflugort = "Wien", Zielort = "London", Datum = DateTime.Now.AddHours(1)
                    };
                    var f3 = new Flug {
                        Abflugort = "Graz", Zielort = "Hamburg", Datum = DateTime.Now.AddHours(2)
                    };
                    var f4 = new Flug {
                        Abflugort = "Hamburg", Zielort = "Graz", Datum = DateTime.Now.AddHours(3)
                    };
                    var f5 = new Flug {
                        Abflugort = "Hamburg", Zielort = "Wien", Datum = DateTime.Now.AddHours(4)
                    };
                    var f6 = new Flug {
                        Abflugort = "Graz", Zielort = "Hamburg", Datum = DateTime.Now.AddHours(5)
                    };
                    var f7 = new Flug {
                        Abflugort = "Wien", Zielort = "London", Datum = DateTime.Now.AddHours(6)
                    };

                    var b1 = new Buchung {
                        PassagierId = 4711, Preis = 300
                    };
                    f1.Buchungen.Add(b1);

                    ctx.Fluege.AddRange(f1, f2, f3, f4, f5, f6, f7);
                    ctx.SaveChanges();
                }
            }

            using (FlugDbContext ctx = new FlugDbContext())
            {
                var all = ctx.Fluege.ToList();
                Debug.WriteLine(all.Count);
            }
        }
示例#10
0
        static FlightManager()
        {
            using (FlugDbContext ctx = new FlugDbContext())
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();

                if (!ctx.Flights.Any())
                {
                    var f1 = new Flight {
                        From = "Graz", To = "Hamburg", Date = DateTime.Now
                    };
                    var f2 = new Flight {
                        From = "Vienna", To = "London", Date = DateTime.Now.AddHours(1)
                    };
                    var f3 = new Flight {
                        From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(2)
                    };
                    var f4 = new Flight {
                        From = "Hamburg", To = "Graz", Date = DateTime.Now.AddHours(3)
                    };
                    var f5 = new Flight {
                        From = "Vienna", To = "London", Date = DateTime.Now.AddHours(4)
                    };
                    var f6 = new Flight {
                        From = "Graz", To = "Hamburg", Date = DateTime.Now.AddHours(5)
                    };
                    var f7 = new Flight {
                        From = "Vienna", To = "London", Date = DateTime.Now.AddHours(6)
                    };

                    var b1 = new Booking {
                        PassengerId = 4711, Price = 300
                    };
                    f1.Bookings.Add(b1);

                    ctx.Flights.AddRange(f1, f2, f3, f4, f5, f6, f7);
                    ctx.SaveChanges();
                }
            }
        }
        public void Merge(Flight flight) {

            using (FlugDbContext ctx = new FlugDbContext())
            {
                ctx.ChangeTracker.TrackGraph(flight, (node) => {
                    node.Entry.State = EntityState.Modified;
                });
                ctx.SaveChanges();
            }
        }
 public void Delete(Flight flight)
 {
     using (FlugDbContext ctx = new FlugDbContext())
     {
         ctx.Flights.Remove(flight);
         ctx.SaveChanges();
     }
 }