• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to get related data from database in ASP.NET Core MVC

Resolved: How to get related data from database in ASP.NET Core MVC

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am new one at that type development and I’m wondering how can I get related data.
I have 2 tables AspNetUsers and Accounts. In Accounts table there are only 3 columns Id, UserId join AspNetUsers table, and Amount. So, what I want to do, is just get this account information for current logged in user.
I was trying something that I have found in documentation, it works, but shows strange result:
Index.cshtml:
Index.cshtml.cs:
I was debugging this code with breakpoints and had found, that there is correct information in account, but on page it shows like this:
What’s wrong? How can I fix this? Thanks.

Answer:

DisplayNameFor displays name for the model (also your value is in account.Amount, not just account).
Just change to:

If you have better answer, please add a comment about this, thank you!

asp.net-core-mvc c#
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Resolved: How to get Union type from an array of objects in Flow?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.