I am doing a query to a db using Entity Framework, with this result i do more queries to check other things. So my question is, how can i do multiple selections in one query?.
For example:
var cars = db.Cars.ToList();
foreach (var car in cars)
{
var owners = db.Owners.Where(x => x.CarID == car.ID).Count();
}
So, i want to have the cars and the owners in the same result of a query.
I will apreciate an answer.
You can use a projection:
The result is a list of anonymous objects where each element has a
Carand anOwnerCountproperty.