public class Employee
{
[Key]
public int EmployeeID { get; set; }
public string Name { get; set; }
public int DesignationID { get; set; }
public virtual Designation Designation { get; set; }
}
(from emp in dc.Employee
select new Employee { Employee = emp , Designation = emp.Designation }).Single();
它給我就行了錯誤"Models.Employee does not contain a definition for Employee"
Employee = emp
Linq查詢錯誤
你能告訴您的視圖模型(員工)? –
更新了我的文章 –
這是正確的,您的類名爲'Employee'沒有名爲'Employee'的屬性。根據你的'select'子句,你試圖將'Employee'的一個實例插入到它自己中。 –