【发布时间】:2011-12-21 05:58:59
【问题描述】:
您好,我想在 LINQ 实体框架中使用这个......
select Empame,EmpSalary,EmpDepartment,(select CountryName from Countries c where c.ID = Employees.EmpCountry) as Country,(select StateName from dbo.States c where c.ID = Employees.EmpState)as States from Employees
我试过这个它给出的错误在这里输入代码
public ActionResult Index()
{
var Employee = (from e in _db.Employee
select new
{
Empame = e.Empame,
EmpSalary = e.EmpSalary,
EmpDepartment = e.EmpDepartment,
EmpCountry = (from c in _db.Country
where (c.ID.ToString() == e.EmpCountry)
select c),
EmpState = (from s in _db.States
where (s.ID.ToString() == e.EmpState)
select s)});
return View(Employee);
}
无法将类型“System.Linq.IQueryable”隐式转换为“字符串”
【问题讨论】:
标签: linq entity-framework