Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- using (var db = new BloggingContext())
- {
- // Create and save a new Blog
- Console.Write("Enter a name for a new Blog: ");
- var name = Console.ReadLine();
- var blog = new Blog { Name = name };
- db.Blogs.Add(blog);
- db.SaveChanges();
- // Display all Blogs from the database
- var query = from b in db.Blogs
- orderby b.Name
- select b;
- Console.WriteLine("All blogs in the database:");
- foreach (var item in query)
- {
- Console.WriteLine(item.Name);
- }
- Console.WriteLine("Press any key to exit...");
- Console.ReadKey();
- }
- }
- }
- //--CONSOLE--
- //Enter a name for a new Blog: ADO.NET Blog
- //All blogs in the database:
- //.NET Framework Blog
- //ADO.NET Blog
- //The Visual Studio Blog
- //Press any key to exit...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement