Entity Framework: getting objects not directly related

I am using Entity Framework for my .NET application. I also managed to return the objects and their objects associated with it (very convenient), but it is difficult for me to get the objects of these objects.

 IEnumerable<Lot> i = (((ObjectSet<Car>)_carRepository.GetQuery())
                                    .Include(a => a.CarTypes).Take(10).ToList()

This works, and I can access carTypes, however, I cannot figure out how to access tables related to CarTypes (for example, tables that have fields related to car types).

I tried to use Join, but I was not able to figure out how to make it work correctly.

All help was appreciated.

+3
source share
2 answers

Include , , , . , .Include( "CarTypes.Company" ), . Include, - ..INCLUDE( "CarTypes" ). ( "SomeOtherTypeFromTheSameParentAsCar" ).

, Include , Include , , , . , , - .

EF4 , ​​ (, , , ).

+1

, ... , -

.Include(a => a.CarTypes.Company) 

, . EF .

0

Source: https://habr.com/ru/post/1751663/


All Articles