Join Jess Chadwick for an in-depth discussion in this video Read from a database using Entity Framework, part of Learn ASP.NET Core MVC: The Basics.
- Now that I've shown you how to write data to a database,…let's see how to read that data back out again…so that we can display it to our users.…The nice thing about the DbSet Type is…that it acts like a normal collection, which means…that you can interact with it through link statements.…For example, if I want to get all of the blog posts…to display on the blog landing page,…I'll simply replace the existing hard-coded data…in the IndexAction with a call…to ToArray on the Posts Property.…
This will retrieve all of the posts from the database,…and this is not actually what I want to do here.…I really just want to get the couple of latest posts.…So what I really want to do is order the posts…by their posted date with the most recent first…and then take the first couple of them.…Once I've done that, I can navigate…to the blog landing page and see these posts.…I can even update this page to link to each individual post.…
Remember back when I first introduced the ActionLink Helper…and mentioned that this last property…
- Building blocks of ASP.NET Core applications
- Creating a new project
- Responding to HTTP requests
- Serving static files
- Understanding the MVC pattern
- Handling requests with controllers
- Rendering HTML with Razor
- Rendering data, view markup, and view logic
- Creating HTML forms
- Validating form data
- Reading and writing from a database with Entity Framework
- Improving the user experience
- Exposing data with a web API
- Securing your ASP.NET application
Skill Level Intermediate
1. The Basics
2. The Model-View-Controller (MVC) Pattern
Understand routing4m 24s
3. Render HTML with Views
4. Work with Data
5. Improve User Experience with Ajax and Web APIs
6. Secure Your Application
Next steps1m 42s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.