0
public IActionResult Index(){
     return View(_context.Announcements.Include(x => x.Automobile).Include(x=>x.Location));
}

And, I want to show Location info on the view. However, on the view data of location can not be show. On the view, location data shows Turbo.Models.Location.

@foreach(var announce in Model)
{
 <p>@announce.Location</p>
}

I wrote this code on the view.

How can i solve this problem?

1 Answer 1

2

Everything is good but you have one mistake on the view.

You should write

@foreach(var announce in Model)
{
 <p>@announce.Location.Name</p>
}

Because if you are write @announce.Location you are showing only location of model. However, if you are writing @announce.Location.Name you are giving data on the view.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.