Created
January 19, 2018 14:51
-
-
Save alieniasty/05749a0c6d5bd45aec35b3df99b572c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
There are options to disable Lazy Loading in an Entity Framework. | |
After turning Lazy Loading off, you can still load the entities by explicitly calling the Load method for the related entities. | |
*/ | |
User usr = dbContext.Users.FirstOrDefault(a => a.UserId == userId); | |
dbContext.Entry(usr).Reference(usr => usr.UserDetails).Load(); | |
/* | |
There are two ways to use Load method: | |
.Reference - to load single navigation property | |
.Collection - to load collections. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment