In this article, we will learn about how to Insert, Update and Delete Records in ASP.NET MVC 5.
LET'S START ASP.NET MVC 5 WITH
In this example, I am going to create a simple student registration form in MVC5 using CRUD (Create, Read, Update and Delete) Operation. In this tutorial, We will use entity framework.
<pre>
<code class="csharp">
public List<RecruitmentRegistrationModel> GetUserRegistrationRecord(RecruitmentRegistrationModel model, int ProcId)
{
var sqlParam = new SqlParameter[]{
new SqlParameter { ParameterName = "@ProcId" , Value =ProcId },
new SqlParameter { ParameterName = "@Id" , Value =model.ApplicationPostId },
new SqlParameter { ParameterName = "@Gender" , Value =model.Gender??"" },
new SqlParameter { ParameterName = "@Age" , Value =model.Age??0 },
new SqlParameter { ParameterName = "@TotalExp" , Value =model.TotalExp??0 },
new SqlParameter { ParameterName = "@EmployerType" , Value =model.EmployerType??"" }
};
var sqlQuery = @"proc_GetUserRegistrationRecord @ProcId,@Id,@Gender,@Age,@TotalExp,@EmployerType";
var res = this.Database.SqlQuery<RecruitmentRegistrationModel>(sqlQuery, sqlParam).ToList();
return res;
}
</code></pre>









