I have the following Linq statement:

car car = db.cars
              .Include("wheels")
              .Include("windows")
              .Where(c => c.id == id)
              .FirstOrDefault();

I have lazy loading turned off. I want to return a single car with several wheels and several windows, but this returns a one wheeled car with just one window. How can I return all the children in this query, whilst still returning just one car?

I should also note that this is a many-to-many relationship, so a wheel can be assigned to many cars.

1

There are 1 answers

0
trees_are_great On

A bit of a hack to get around some Sybase Ase issues when used with the Sybase data connector, but this works:

var carSet = db.cars
              .Include("wheels")
              .Include("windows")
              .Where(c => c.id == id);

var car = carSet.FirstOrDefault();