locked
How to apply join for models in view using entity framwork RRS feed

  • Question

  • User1052662409 posted

    Hi All,

    In my MVC application I am using Controller with views using Entity Framework.

    So the result I got below code in my view

    @Html.DisplaylFor(model => model.updatedby)

    Here the issue is that model => model.updatedby gives the User_Id and here I need name of that user.

    My question is how can I put a join with the tblUser in view bt using User_Id? or do I need to follow another approach?

    As I found that my application doesn't have complex logic so I choose  Controller with views using Entity Framework.

    Please suggest

    Tuesday, May 21, 2019 1:26 PM

Answers

  • User1120430333 posted

     or do I need to follow another approach?

    https://www.tutlane.com/tutorial/aspnet-mvc/how-to-use-viewmodel-in-asp-net-mvc-with-example

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 21, 2019 4:21 PM

All replies

  • User-323149085 posted

    Im not sure I understand what u need but 

    here r few ways you can learn how to get the user what ever data from the table as u can c , user manger & get the value that u need is the easy way 

     ViewBag.user =  _userManager.GetUserId(this.User);
                ViewBag.name =  _userManager.GetUserName(this.User);
                ViewBag.userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

    Tuesday, May 21, 2019 2:26 PM
  • User1120430333 posted

     or do I need to follow another approach?

    https://www.tutlane.com/tutorial/aspnet-mvc/how-to-use-viewmodel-in-asp-net-mvc-with-example

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 21, 2019 4:21 PM