ASP. net mvc Notes, asp. netmvcnotes
Receive data directly in the form of parameters
The UpdaetModel in the Controller updates the Model to obtain the submitted data.
Service:
The Nuget Package Manager in solution manages the Nuget packages in solution.
Two Methods for model binding in Controller:
1. Bind formulation requires model binding to transmit data to the Controller.
Public ActionResult Edit_Post ([Bind (Include = "Gender, City, DateOfBirth")] Employee)
2. In UpdateModel, pass the parameter to be updated or not to be updated
UpdateModel <Employee> (employee, null, null, new string [] {"Name "});
3. Define the IEmployee interface. The Employee inherits from the IEmployee interface.
UpdateModel <IEmployee> (employee );
The Delete action of data must be performed in the Post data.
Field attribute control in EF, for example, [Required] and [Display (Name = "")] must be processed in partial class.
When editing information, you do not need to update the field. If you do not need to update the Name.
Lambda expression to count the number of employees in the Department
If you specify a View with a Suffix in Return View () in Controller, such as index. cshtml, you need to pass the complete path: