現在一直存在此錯誤。 基本上我有2 C#類庫 HeldDeskBusinessData和HelpDeskBusinessUser(縮短標題)無法將類型'System.Collections.Generic.List <Data.emp>'隱式轉換爲'System.Collections.Generic.List <User.Employee>'
從HelpDeskBusinessData
public List<Employee> GetAll()
{
HelpDeskDBEntities dbContext = new HelpDeskDBEntities();
List<Employee> employees = dbContext.Employees.ToList();
List<Employee> busEmployees = new List<Employee>();
try
{
foreach (Employee emp in employees)
{
Employee empBus = new Employee();
empBus.Title = emp.Title;
empBus.FirstName = emp.FirstName;
empBus.LastName = emp.LastName;
empBus.PhoneNo = emp.PhoneNo;
empBus.Email = emp.Email;
empBus.DepartmentID = emp.DepartmentID;
empBus.EmployeeID = emp.EmployeeID;
busEmployees.Add(empBus);
}//end foreach
}//end try
catch (Exception ex)
{
throw new Exception(ex.Message);
}//end catch
return busEmployees;
}//end getallemployees
從HelpdeskBusinessuser包含一個錯誤(標籤)
public List<EmployeeBusinessUser> GetAll()
{
EmployeeBusinessData empBD = new EmployeeBusinessData();
List<Employee> empL = new List<Employee>();
List<EmployeeBusinessUser> empBU = new List<EmployeeBusinessUser>();
empL = empBD.GetAll(); /*error cant explicitly convert. */
try
{
foreach (Employee emps in empL)
{
EmployeeBusinessUser empBus = new EmployeeBusinessUser();
empBus.Title = emps.Title;
empBus.FirstName = emps.FirstName;
empBus.LastName = emps.LastName;
empBus.PhoneNo = emps.PhoneNo;
empBus.Email = emps.Email;
empBus.DepartmentID = emps.DepartmentID;
empBU.Add(empBus);
}//end foreach
}//end try
catch (Exception ex)
{
ErrorRoutine(ex, "EmployeeBusinessUser", "GetAll");
}
return empBU;
}//end getallemployees
人有一個想法怎麼解決?
它在'HelpDeskBusinessData'中的哪一行會引發錯誤?這裏沒有任何「Data.Emp」類。這是你正在使用的課程嗎? –
@JeroenVannevel:他們縮短了標題。 – ChiefTwoPencils
@BobbyDigital:我不會認爲,考慮命名空間也是不同的。 –