Currently I’m using Asp.net MVC for an ongoing application, to use the sp’s I’m using Ado.net,Is there any other way to implement SP in the code rather than using ado.net.
public class EmployeeBusiness_Layer
{
string connectionString =
ConfigurationManager.ConnectionStrings[“DBCS”].ConnectionString;
public IEnumerable<Employee> Employees
{
get
{
List<Employee> employees = new List<Employee>();
using (SqlConnection con = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("spGetAllEmployees", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Employee employee = new Employee();
employee.ID = Convert.ToInt32(rdr["Id"]);
employee.Name = rdr["Name"].ToString();
employee.Gender = rdr["Gender"].ToString();
employee.City = rdr["City"].ToString();
employee.DateOfBirth = Convert.ToDateTime(rdr["DateOfBirth"]);
employees.Add(employee);
}
}
return employees;
}
}
}
I need an other alternative instead of using Ado.net
New contributor
Abishek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1