我正在尝试将列表的新实例实例化为从不同 .dll 类中的方法接收的对象。当我这样做时,我得到一个类型转换错误:
无法将 System.Collections.Generic.List<HelpDeskBusinessDataObject.Employee> 类型隐式转换为 System.Collections.Generic.List<HelpDeskBusinessUserObject.Employee>
这是我实例化它的方式:
public List<EmployeeBusinessUser> GetAll()
{
EmployeeBusinessData empData = new EmployeeBusinessData();
List<Employee> employees = new List<Employee>();
List<EmployeeBusinessUser> retEmployees = new List<EmployeeBusinessUser>();
try
{
//Here is where I am trying to get the list assigned to what is
//returned from the method call
employees = empData.GetAll();
}
catch (Exception ex)
{
ErrorRoutine(ex, "EmployeeUserData", "GetAll");
}
return retEmployees;
}
谢谢您的帮助。
编辑:GetAll() 方法:
public List<Employee> GetAll()
{
HelpDeskDBEntities dbContext = new HelpDeskDBEntities();
List<Employee> employees = new List<Employee>();
try
{
employees = dbContext.Employees.ToList();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return employees;
}