From the course: .NET Essentials: LINQ for Databases
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Use EF navigation properties instead of joins - .NET Tutorial
From the course: .NET Essentials: LINQ for Databases
Use EF navigation properties instead of joins
- [Instructor] In SQL, we use JOIN to combine the contents of two tables based on a logical relationship between the tables. There are JOIN query operators available in LINQ, however, because of the way Entity Framework defines relationships between model classes with the navigation properties, we don't need to use JOINs for most Entity Framework queries. So let's take a look at some relationships in our models. I sometimes use the word models and I also use the word table when talking about this but that's because there's a mapping between the two. So I'm looking at a diagram that's in Visual Studio. I'm looking at NorthwindModel.edmx I've added a second diagram here which is a simplified version of the relationships between all the tables and my goal in my query is to query the Order Detail model. I can get UnitPrice and Quantity but I can also get details from the other two tables because of these…
Contents
-
-
-
-
-
-
-
(Locked)
Projection, get fewer columns2m 19s
-
(Locked)
Paging with Take and Skip1m 49s
-
(Locked)
Use Find for faster search by key1m 58s
-
(Locked)
Use EF navigation properties instead of joins3m 4s
-
(Locked)
Use the Contains method for1m 36s
-
(Locked)
Organize query results into groups with GroupBy3m 7s
-
(Locked)
Flatten child collections with SelectMany1m 36s
-
(Locked)
Find data within a date range1m 20s
-
(Locked)
-