Tuesday 15 September 2015

asp.net mvc - Display other fields besides just the foreign key Id in a list using Linq to sql -


When I display a list of records, what is the best way to display a user name instead of author_id (foreign key) I'm using SQL on this project from Linux.

  & lt;% foreach (Miscellaneous items in the model) {%> & Lt; TR & gt; & Lt; TD & gt; & Lt;% = Html.Encode (item.Title)% & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.Encode (item.Author_Id)%>  

I think I have to give something to the controller or if I use the Lambda expression to call a specific area If you make your model, then your FK was in place, I can do it on foreign key values.

So on your model should be an author's property, which is linked to the author table, then you have Model.Author.Name.


No comments:

Post a Comment