MVC route Query, what is the role of routing??

Source: Internet
Author: User

The Query method in model

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;namespacemvcapplication Routing contact. models{ Public classCARBF {PrivateMastercardatacontext _context =NewMastercardatacontext ();  PublicList<car>Select () {return_context.car.tolist (); }             PublicList<car> Selectbybrand (stringBrandcode) {                varQuery=_context.car.where (p=>p.brand==Brandcode); returnquery.            ToList (); }             PublicList<car> Selecbyprice (decimalLowdecimalupp) {                varquery = _context.car.where (P=>p.price>=low &&p.price<=upp); returnquery.            ToList (); }    }}

The code in the controller

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;usingmvcapplication routing contact. Models;namespacemvcapplication Routing contact. controllers{ Public classHomecontroller:controller {//        //GET:/home/         PublicActionResult Index () {returnView (); }         PublicActionResult Findbyprice (decimalLowdecimalupp) {List<Car> list =NewCARBF ().            Selecbyprice (Low,upp); returnView (list); }    }}


Two views of the code

@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>Index</title>@using (Html.BeginForm ("Findbyprice","Home", FormMethod.Post)) {            <div>highest Price: @Html. TextBox (" Low"); Lowest Price: @Html. TextBox ("upp"); </div> <input id="Submit1"Type="Submit"Value="Enquiry"/>        }    </div></body>@using mvcapplication routing contact. Controllers; @using mvcapplication routing contact. Models; @model List<Car>@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>Findbyprice</title>@foreach (Car datainchModel) {            <li>@[email protected]</li>             }        </ol> </div></body>

MVC route Query, what is the role of routing exactly??

Related Article

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.