Here is a linq query that assigns data to a viewmodel. It works great.
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();
Here is code that tries to perform a join and assign the data to a viewmodel. It does not work. the code editor tells me that x does not have a method or definition for 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
});
What am I missing?
You’ve already selected BranchName, which I suppose is a string, so there’s no BranchName property of x: