如何使用C#在Linq to SQL中编写此SQL。我无法将状态表连接到ConsumerApplications和RepairOrderEstimates以正常工作。感谢。
select ca.ConsumerAppID,
ca.LastName,
statConsumerApp.StatusName,
statRepairOrderEstimates.StatusName
from ConsumerApplications ca
join RepairOrderEstimates
on ca.RepairOrderEstimateID = RepairOrderEstimates.RepairOrderEstimateID
join Statuses statConsumerApp
on ca.StatusID = statConsumerApp.StatusID
join Statuses statRepairOrderEstimates
on RepairOrderEstimates.StatusID = statRepairOrderEstimates.StatusID
答案 0 :(得分:2)
我认为你可以用
之类的东西来做到这一点from ca in ConsumerApplications
join est in RepairOrderEstimates on ca.RepairOrderEstimateID == est.RepairOrderEstimateID
join statConsumerApp in Statuses on ca.StatusID == statConsumerApp.StatusID
join statEstimate in Statuses on est.StatusID == statEstimate.StatusID
select new {
ConsumerAppID = ca.ConsumerAppID,
LastName = ca.LastName,
AppStatus = statConsumerApp.StatusName,
EstimateStatus = statEstimate.StatusName,
}