Answer the question
In order to leave comments, you need to log in
EF Core how to output dependent data?
Good evening, please.
There are 2 classes, the first class is phones, another class is models, a bunch of many to one:
public Model()
{
Phones = new List<Phone>();
}
Answer the question
In order to leave comments, you need to log in
in controller
var model = context.Model.Include(i=>i.Phones)
return View(model)
@model Model
@foreach (var phone in Model.Phones)
{
}
1. Never mix Domain models and DTO models. Read about DDD
2. You have Model, Phone, etc. in Domain.
Return from the controller must be done through DTO simple classes with get; set properties. To do this, you need to map your domain models to DTOs and return them to the View.
At the same time, DTO objects should be made as convenient as possible for the View.
It is difficult to understand what is wrong with you and why it cannot be processed even in your case.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question