MVC shows detailed records without Entity Framework

Source: Internet
Author: User

Read this article, "MVC uses non-Entity Framework to display data in view (ii)" Http://www.cnblogs.com/insus/p/3364482.html learned to display data from data tables in a database on a view. In a situation, I need to click on a record to see its detailed data.

The implementation of this function in MVC is actually very simple. We can first create a stored procedure in the database ([dbo].[ Usp_fruitcategory_getbyprimarykey]):


The primary key value of the incoming record to get the record. To modify the Fruitcategoryentity class in the models directory, add a function that returns ienumerable<fruitcategory> (Getfruitcategorybyprimarykey (byte FRUITCATEGORY_NBR)):

Next, we can modify the CategoryController.cs class in the Controllers directory.

Finally, the index.cxhtml view in the category directory, add a "detailed" column, and then create a details.cshtml view in this directory to display the details.



The most popular source program (. NET Framework 4.5 + C #) and Database (SQL Server 2014) files:
Http://download.cnblogs.com/insus/MVC/InsusMVCSiteCS_2013Oct13.rar



The following content was added on 2013-10-13 14:05, refactoring the Fruitcategoryentity class:


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.