Пример #1
0
        public static void Main(string[] args)
        {
            using (var context = new pubsContext())
            {
                Boek boek = context.Boeken.SingleOrDefault(b => b.TitleId == "BU9999");

                context.Boeken.Remove(boek);

                context.SaveChanges();
            }
            // InsertBoek();
            // DureBoekenQuery();
        }
Пример #2
0
        private static void InsertBoek()
        {
            using (var context = new pubsContext())
            {
                var mijnboek = new Boek
                {
                    Price   = 13.37M,
                    Title   = "How to write a book",
                    TitleId = "BU9999",
                    Type    = "Business",
                };
                context.Boeken.Add(mijnboek);

                context.SaveChanges();
            }
            Console.WriteLine("It has been done");
        }
Пример #3
0
        private static void DureBoekenQuery()
        {
            using (var context = new pubsContext())
            {
                var dureBoekenQueryEager = from boek in context.Boeken.Include(t => t.Pub)
                                           where boek.Price > 20.00M
                                           select boek;
                var dureBoekenQuery = from boek in context.Boeken
                                      where boek.Price > 20.00M
                                      select new
                {
                    boek.Price,
                    boek.Title,
                    //boek.Pub.PubName
                };

                Console.WriteLine("Dit is de nieuwe!!");
                foreach (var item in dureBoekenQuery)
                {
                    Console.WriteLine($"{item.Price:C2} - {item.Title} - item.PubName");
                }
            }
        }