Multi-Table Association resolution data in MVC display

Source: Internet
Author: User

Because some of the child table's fields are foreign keys to the parent table, only one key value is displayed under normal conditions.
such as the highlight column, if so shown, is indeed unfriendly.


If you are creating or editing a mode, we can use the drop-down menu to solve, such as "html.dropdownlistfor Exercise (2)" http://www.cnblogs.com/insus/p/3383277.html. But in the display, we can write a function to implement a friendly name display, but this practice, in MVC, is really a performance difference. What is to be done, then, a more eclectic approach?

Insus.net solution, is to get the sub-table data, do a multi-table association, you can refer to the "MVC 5 display, creation, editing, deletion and other functions practice" http://www.cnblogs.com/insus/p/3372916.html The first table function and a stored procedure are:





After associating the multiple tables, the foreign and foreign key values are displayed directly [Fruitcategory_nbr],[categoryname].

Then modify the FruitKind.cs class under models to add a property:



Finally, in the place where the view is displayed, after modifying the line comment out, add the # # line code.



OK, let's do the demo in real Time:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.