model.ListManagerReviewerMapping = (from a in wallet.OM_Employee
join m in wallet.APPR_ManagerMapping
on a.AssociateId equals m.AssociateId
where m.ManagerId==Context.UserId.Value **into** MM
from leftjoinresult in M.DefaultIfEmpty()
where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today)
select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping()
{
Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode),
AssociateId = a.AssociateId,
AssociateCode = a.AssociateCode,
AssociateName = a.AssociateName
}).ToList();
答案 0 :(得分:1)
//Remove brackets and .ToList();
model.ListManagerReviewerMapping = from a in wallet.OM_Employee
join m in wallet.APPR_ManagerMapping
on a.AssociateId equals m.AssociateId
where m.ManagerId==Context.UserId.Value **into** MM
from leftjoinresult in M.DefaultIfEmpty()
where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today)
select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping()
{
Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode),
AssociateId = a.AssociateId,
AssociateCode = a.AssociateCode,
AssociateName = a.AssociateName
};
答案 1 :(得分:1)
您需要对第一个查询使用Where
扩展方法,因为查询使用DefaultIfEmpty
左连接(请注意,into
子句后您不能使用where
由于where
必须跟select
一起完成查询):
model.ListManagerReviewerMapping = (from a in wallet.OM_Employee
join m in wallet.APPR_ManagerMapping.Where(x => x.ManagerId == Context.UserId.Value)
on a.AssociateId equals m.AssociateId into MM
from leftjoinresult in MM.DefaultIfEmpty()
where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today)
select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping()
{
Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode),
AssociateId = a.AssociateId,
AssociateCode = a.AssociateCode,
AssociateName = a.AssociateName
}).ToList();
类似问题: