Ejemplo n.º 1
0
        static void addBlogValues()
        {
            using (var db = new ExistingEFDatabaseContext())
            {
                db.Blog.Add(new Blog {
                    Url = "https://google.com"
                });
                db.Blog.Add(new Blog {
                    Url = "https://yahoo.com"
                });
                db.Blog.Add(new Blog {
                    Url = "https://bing.com"
                });
                db.Blog.Add(new Blog {
                    Url = "https://myspace.com"
                });
                db.Blog.Add(new Blog {
                    Url = "https://shazam.com"
                });

                var count = db.SaveChanges();

                db.Dispose();

                Console.WriteLine("{0} records have been added to the database.", count.ToString());
            }

            prompt();
        }
Ejemplo n.º 2
0
        static void deleteBlogValues()
        {
            using (var db = new ExistingEFDatabaseContext())
            {
                var allrecords = from x in db.Blog select x;
                db.Blog.RemoveRange(allrecords);

                var count = db.SaveChanges();

                db.Dispose();

                Console.WriteLine("{0} records have been removed to the database.", count.ToString());
            }

            prompt();
        }
Ejemplo n.º 3
0
        static void showBlogValues()
        {
            using (var db = new ExistingEFDatabaseContext())
            {
                foreach (var blog in db.Blog)
                {
                    Console.WriteLine(" - {0}", blog.Url);
                }

                var count = db.Blog.Count();
                db.Dispose();

                Console.WriteLine("{0} records have been displayed.", count.ToString());
            }

            prompt();
        }