Database Reference
In-Depth Information
Figure 4-13. Editing an app category
How It Works
The entire code base is divided into three parts:
1.
Model with DbContext class (Listing 4-1)
2.
Controller code (Listing 4-2)
3.
View code (Listing 4-3 and Listing 4-4)
The controller is the largest piece of the code, and it is the heart of the functionality of all the operations. The
views are created on the basis of action methods in the Controller. All of the code that is used to fetch, create, update,
and delete is addressed in the action methods. Whenever a view is accessed through a URL or another view, the
corresponding action method of that operation is called upon in the controller to perform that action. We selected the
scaffolding option while creating new views, which automatically generates the HTML code of edit, create, and list
using the Razor view engine, depending upon the scaffolding option selected.
4-2. Building a Search Query
Searching data is a very basic functionality that most of the applications have. It is very dynamic in nature, as users
can use any criteria, if provided, to search, or none. So we discuss below in detail the basic implementation of search
functionality.
Problem
You want to build a search page in ASP.NET MVC 4 using Entity Framework.
 
Search WWH ::




Custom Search