这是一个将数据分配给视图模型的 linq 查询。它工作得很好。
var data = (from C in db.CaseComplaints
where C.CasesID == caseid
select C.ComplaintCode).ToList().Select(x => new CaseComplaintsViewModel()
{
ComplaintCode = x.ComplaintCodeName,
ComplaintType = x.ComplaintType
}).ToList();
这是尝试执行连接并将数据分配给视图模型的代码。这没用。代码编辑器告诉我 x 没有 BranchName 的方法或定义
var data = (from branch in db.Branches
join customer in db.Customers
on branch.BranchID equals customer.BranchID
where customer.BranchID == bid
select branch.BranchName).ToList().Select(x => new CaseResponsibleBranchViewModel()
{
BranchName = x.BranchName
});
我错过了什么?