How To Create .NET Core Web API Without Entity Framework

In this code, you will see how to create .NET Core Web API without Entity Framework.

public List < Employee > EmployeeData(Employee emp) {
    SqlConnection connection = new SqlConnection();
    connection.ConnectionString = "Data Source=Your Server IP;Initial Catalog=DB Name;User ID=Your User Id;Password=**8";
    connection.Open();
    string procedureName = "Employeedata_Usp";
    var result = new List < Employee > ();
    using(SqlCommand command = new SqlCommand(procedureName, connection)) {
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.AddWithValue("@action", emp.action);
        command.Parameters.AddWithValue("@Eid", emp.eid);
        command.Parameters.AddWithValue("@Name", emp.name);
        command.Parameters.AddWithValue("@Email", emp.email);
        command.Parameters.AddWithValue("@Company", emp.company);
        command.Parameters.AddWithValue("@Loc", emp.loc);
        using(SqlDataReader reader = command.ExecuteReader()) {
            while (reader.Read()) {
                //int id = int.Parse(reader[0].ToString());
                //string name = reader[1].ToString();
                //float? age = float.Parse(reader[2]?.ToString());
                //string Country = reader[3].ToString();
                //float? savings = float.Parse(reader[4]?.ToString());
                if (emp.action.ToString() != "" && emp.action.ToString() != "select") {
                    emp.message = reader["message"].ToString();
                    Employee tmpRecordMsg = new Employee() {
                        message = emp.message
                    };
                    result.Add(tmpRecordMsg);
                } else {
                    emp.name = reader["name"].ToString();
                    emp.eid = reader["eid"].ToString();
                    emp.email = reader["email"].ToString();
                    emp.company = reader["company"].ToString();
                    emp.loc = reader["loc"].ToString();
                    Employee tmpRecord = new Employee() {
                        eid = emp.eid,
                            name = emp.name,
                            email = emp.email,
                            company = emp.company,
                            loc = emp.loc,
                            message = emp.message
                    };
                    result.Add(tmpRecord);
                }
            }
        }
        connection.Close();
    }
    return result;
}