I have an entity called Position with foreign key to itself: int Id; and int ParentId;.This gives me two navigation properties: Position Parent; and List<Position> Children;. When I'm loading the entire table into EF context (tracked), I'd like EF to populate those properties without emitting additional SQL joins (since all participating entities are being loaded anyways). Is there any way to achieve this during query creation or later, maybe something like db.Entry(positions[0]).Collection(x => x. Children).Load();, but limited to already tracked entities?
In Entity Framework Core, how to populate self-referencing navigation collection without additional Include (using only entities already tracked)?
27 views Asked by Ivan Koshelev At
1
There are 1 answers
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in ENTITY-FRAMEWORK-CORE
- Will it slow down the performance when Unit of work pattern is used with EF Core
- Entity Framework Core 8 dbcontext - can't add some rows in many-to-many relationship
- Upsert huge amount of data by EFCore.BulkExtensions
- .NET Core 8, how can I add properties to user account that contains multiple values?
- How to load data from a different context in Entity Framework Core?
- Passing GUID value through SqlQuery will raise the error: invalid input syntax for type uuid
- The specified data type in the EF modelBuilder doesn't correspond to the one that is created
- EntityFrameworkCore.DbUpdateException: Unable to delete row, SQL Syntax error
- Create one entity for multiple tables?
- I'm getting an error, when trying to communicate with db, it seems like something with verses, but I've already changed it and the error continues
- Issue with Entity Framework Core: .Include() and .AsNoTracking() not displaying expected related entities
- Entity Framework Core 8 throws "Method not found: 'Void CoreTypeMappingParameters..ctor" error
- EF Core is creating a table not in the migration
- Can I share a List<T> property across multiple queries via a tracking DbContext?
- Revert database context to previous state EF Core 7
Related Questions in NAVIGATION
- Why might react-router navigate(-1) go back two routes/pages?
- In @react-navigation's Tab.Navigator, I aim to lock the final screen while allowing the rest to scroll
- (ros melodic) Lidar odometry is not working well
- How to jump to a div using keyboard shortcuts?
- Flutter: How to use a BottomSheet in a BottomNavigationBar?
- Force security constraint managed 403 error when hitting restricted page with h:commandLink
- In Entity Framework Core, how to populate self-referencing navigation collection without additional Include (using only entities already tracked)?
- Blogger next previous navigations missing
- Cannot achieve live navigation using js,openstreetmap and leaflet
- Im using mapbox sdk navigation v2 and have a problem with the cycling view
- Assigning sensor information to image coordinates
- Blazor InteractiveServer navigate to external link whilst JWT added to the request headers?
- Navigate to a different page from the side bar drawer without using the bottom navigation bar using persistent flutter package
- WPF C# - Textblock inputs not saving on Navigation to new page?
- React Chrome vs Firefox Navigation is not defined
Related Questions in SELF-JOIN
- In Entity Framework Core, how to populate self-referencing navigation collection without additional Include (using only entities already tracked)?
- Join a table with itself as a concept
- Which Join Condition Order is More Efficient in Spark SQL?
- Self join table where results list the same column twice with different results
- Why self-reference a column from the same table in a SQL subquery?
- Custom Join request on LoRaWAN End Node STM32L0
- Issue with StackOverflowError in Spring Boot application during DTO serialization
- Biquery - how to replace self-join with window function to get +/- 7 days of ids
- Prevent double matches on self referencing table
- R data.table update last values of parameters with some dynamics by id, using shift etc
- Get the students which have attempted exam in current year and at least one previous attempt in last 12 months
- how to find the maximum number of times the customer id logged in consecutively
- Selecting records where autoincrement ID is bigger, but date column is in the past
- Self join inside table by multiple values. SQL, Postgresql
- How to find duplicate items in a table of a database
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
If you have loaded all related positions as tracked entities then you should find that the relationships are already populated when leaving off the
Include. Eager loading is generally recommended as without it EF will only populate references from the tracking cache which might be only an incomplete representation of the state. If you can safely assume that all related positions are loaded and tracked then you can ignore adding theInclude. I'd probably throw a comment in there explaining that at that point all positions should have been loaded. Any optimizations or re-factoring could break your current expected behavior.