asp.net mvc - 'BusinessLayer.EmployeeBusinessLayer' is inaccessible due to its protection level -
in classliberary named (businesslayer)
i have made class employee.cs--->
public class employee { public int employeeid { get; set; } public string employeename { get; set; } public string employeecity { get; set; } public string employeegender { get; set; } public int departmentid { get; set; } }
then added class employeebusinesslayer.cs
class employeebusinesslayer { public ienumerable<employee> employees { { string connectionstring = configurationmanager.connectionstrings["dbcs"].connectionstring; list<employee> employees = new list<employee>(); using (sqlconnection con = new sqlconnection(connectionstring)) { sqlcommand cmd = new sqlcommand("sqlgetallemployees", con); cmd.commandtype = commandtype.storedprocedure; con.open(); sqldatareader rdr = cmd.executereader(); while (rdr.read()) { employee employee = new employee(); employee.departmentid = convert.toint16(rdr["departmentid"]); employee.employeeid = convert.toint16(rdr["employeeid"]); employee.employeename = rdr["employeename"].tostring(); employee.employeecity = rdr["employeecity"].tostring(); employee.employeegender = rdr["employeegender"].tostring(); employees.add(employee); } } return employees; } } }
and when using in project after adding reference showing "businesslayer.employeebusinesslayer' inaccessible due protection level"
public class employeescontroller : controller { public actionresult index() { employeebusinesslayer employeebusinesslayer = new employeebusinesslayer(); list<employee> employees = employeebusinesslayer.employees; return view(employees); } }
you need make employeebusinesslayer accessible controller class.
you can example make public:
public class employeebusinesslayer { ...
Comments
Post a Comment