In my database I have relations, for example, I have a table like:
CarId, Model, Manufacturer, Owner where Owner is a foreign key to another table.
I have a DbSet<Car>
How can I select all columns without Owner in my get action using LINQ?
[HttpGet("[action]")]
public IEnumerable<object> Cars()
{
return _db.Cars.Select(car => new { Id = car.CarId, Model = car.Model, Manufacturer = car.Manufacturer }).AsEnumerable();
}
Is this the right way of doing it? I use Entity Framework Core.