Entity Framework Core supports special LINQ statements that return a single record. Phil demonstrates using these statements and which statements run server side vs. client side. Phil closes this section with a discussion of paging using the Skip and Take LINQ methods.
- [Instructor] First, last, and single…are all designed to return a single record,…but they work a bit differently from each other.…First, or first or default, as one would expect,…returns the first record of a sequence.…And last, and last or default,…returns the last record of a sequence.…The difference between first and first or default…is first will throw an exception,…as will last, if no record is found.…
The or default versions will…return null if nothing is found.…It's also important to note that in the absence…of an order by or an order by descending,…then the data will be returned by the data store order.…So for example, a clustered index in SQL Server.…Single and its companion single or default…returns a single record if more than one record is found,…an exception will be thrown.…
So basically you're setting up an assertion,…there should only be one of these,…if you find more than one, let me know…by throwing an exception.…And lastly, I want to point out that last or default…executes client side.…So if you do a last on a very large table,…
- Entity Framework Core components and projects
- Working with scaffolded files
- Testing with xUnit
- Viewing generated SQL
- Composing queries
- Sorting and filtering results
- Working with aggregates
- Loading related data
- Logging and tracking
- Mapping functions
- Generics and delegates
- Checking concurrency
- Resiliency and transactions
Skill Level Intermediate
Learning Entity Framework Corewith Reynald Adolphe1h 35m Intermediate
1. Get to Know Entity Framework
2. Set the Stage
3. Querying Data: Part 1
4. Querying Data: Part 2
5. Advanced Query Features
6. Persisting Data
7. DbContext Options and Configuration
Thank you1m 23s
- 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.