Sorry the title isn't more specific - I didn't know how to describe this succinctly. I have Trips and Location that have a many-to-many relationship - straightforward except that Locations have no need to know about the Trips that use them. I've created these entities to represent this:
public class Trip
{
public int TripId { get; set; }
public virtual IList<TripLocation> TripLocations { get; set; }
}
public class TripLocation
{
public int TripId { get; set; }
public int LocationId { get; set; }
public virtual Location Location { get; set; }
}
public class Location
{
public int LocationId { get; set; }
// Note: Intentionally no collection of Trips
}
I can get the Trip to eager load it's TripLocations but I can't get the TripLocations to eager load their Locations. I've tried a bunch of combinations fluent configuration and "Include"ing in the query such as
IQueryable<Trip> query = from trip in context
.Include(r =>r.TripLocations)
.Include(r => r.TripLocations.Select(tl => tl.Location))
select ride;
Any suggestions much appreciated!