嗨,我正在尝试在下面的两个表上进行连接,但由于某种原因,我收到了一个错误
var query = (from a in pamsEntities.appraisals
where a.emp_no == employeeId
join b in pamsEntities.AppraisalReadinesses on a.AppraisalReadiness.Code equals b.Code
select new { a, b }).ToList();
我收到错误无法转换匿名类型我对 LINQ 很陌生,所以不确定为什么会发生此错误。
对不起,这就是我厌倦了我不得不修改 telrik 报告的查询,以便我在连接中有描述,以便可以在报告中显示它
public List<appraisal> GetAppraisal(int employeeId)
{
List<appraisal> Appraisals = new List<appraisal>();
try
{
var query = (from a in pamsEntities.appraisals
where a.emp_no == employeeId
join b in pamsEntities.AppraisalReadinesses on a.AppraisalReadiness.Code equals b.Code
select Tuple.Create(a, b)).ToList();
Appraisals = query;//pamsEntities.appraisals.Where(a => a.emp_no == employeeId).ToList();
}
catch (Exception ex)
{
throw new EntityContextException("GetAppraisal failed.", ex);
}
return Appraisals;
}
这是我要复制的 sql 查询
select a.*, b.*
from appraisls a , AppraisalReadiness b
where a.Readiness = b.code
and a.emp_no = emp_code;
where empcode is just a vairable
就是这样