Although there is information on the net that gives you a guide to answer this question, it is normally in English and is distributed in several documents, so I have decided to publish it so that others who are looking for information in Spanish have an idea.
I assume that we know how to relate the entities via the entity framework and what we are going to deal with here is how to retrieve all the information.
problem I have a class structure like this
As I anticipated, we have the entity configured in the ContextBase in such a way that they are related, but I have the problem that I do not know how to retrieve several levels, that is, retrieving master - detail is a piece of cake (there are only 2 levels) but in this case there are 5 levels. How can i do this then?
When reading documentation it said that it was not possible, but it is possible and we will see it later. This Solution has been tested with EF Core 3.1 and 5.0.
We must have the related tables more or less in the base context, you would see something like this
I do not dwell much on this, it is not the objective, but then how do I recover all the information, then the code with comments to explain it.
/// Here is the first level, the relation that includes EVENT AND SUCCESS DATA (you can see the image above) /// here everything is easy master detail with include
///third level here we are going to add Dataecessadif, eventfile, etc. we are going to start /// with datsucesoadif because it has a fourth level so we put a "ThenInclude(b => ///b.datosucesoadifs)" adding this 3rd level and then another "ThenInclude(c => c.Datomatrodanteucesos )" /// which adds a fourth level
///As we have to add another table to the fourth level, it is done by placing another ThenInclude /// but this one has something special, as you can see it cannot be done like the first one because otherwise ///Entity would think it is a fifth level and it is not that's why we tell it that it is still /// the fourth level of this form d.AdifDataEvent.EventConsequence
///Add the others of the third level easily as you can see here
///look here we have an extra table so we can make multilevel calls
in the end something like this
And I hope that it will be of some use to you as it has served me, greetings