linq left join
var list = from SCR in db.SO_ChangeRec
join SMU in db.SP_Material on SCR.UpMaterialNo equals SMU.MaterialNo into temp
from tt in temp.DefaultIfEmpty()
join PR in db.SP_SPReservation on SCR.SOID equals PR.SOID
join SMD in db.SP_Material on SCR.DownMaterialNo equals SMD.MaterialNo
where SCR.DownPartsSN == DownPartsSN
&& SCR.BranchID == BranchID
&& SCR.Status == ESDStaticClass.OverStatus.NotReturned
&& PR.PRStatus == ESDStaticClass.PRStatus.Over
orderby SCR.CreateTime
select new SparePartsChanageExt
{
ChangeRecID = SCR.ChangeRecID,
SOID = SCR.SOID,
DownPartsSN = SCR.DownPartsSN,
DownMaterialNo = SCR.DownMaterialNo,
DownMaterialNoDesc = SMD.MaterialName,
DownYakuan = SMD.YakuanPrice,
RequirementType = ESDStaticClass.RequirementCategory.Borrow,
DownSPMark = SCR.DownSPMark,
UpPartsSN = SCR.UpPartsSN,
UpMaterialNo = SCR.UpMaterialNo,
UpYakuan = tt.YakuanPrice,
PRCode = PR.PRCode,
UpMaterialNoDesc = tt.MaterialName,
StoreAreaType = ESDStaticClass.StoreAreaType.BadStoreArea
};
var list = from SCR in db.SO_ChangeRec
join SMU in db.SP_Material on SCR.UpMaterialNo equals SMU.MaterialNo into temp
from tt in temp.DefaultIfEmpty()
join PR in db.SP_SPReservation on SCR.SOID equals PR.SOID
join SMD in db.SP_Material on SCR.DownMaterialNo equals SMD.MaterialNo
where SCR.DownPartsSN == DownPartsSN
&& SCR.BranchID == BranchID
&& SCR.Status == ESDStaticClass.OverStatus.NotReturned
&& PR.PRStatus == ESDStaticClass.PRStatus.Over
orderby SCR.CreateTime
select new SparePartsChanageExt
{
ChangeRecID = SCR.ChangeRecID,
SOID = SCR.SOID,
DownPartsSN = SCR.DownPartsSN,
DownMaterialNo = SCR.DownMaterialNo,
DownMaterialNoDesc = SMD.MaterialName,
DownYakuan = SMD.YakuanPrice,
RequirementType = ESDStaticClass.RequirementCategory.Borrow,
DownSPMark = SCR.DownSPMark,
UpPartsSN = SCR.UpPartsSN,
UpMaterialNo = SCR.UpMaterialNo,
UpYakuan = tt.YakuanPrice,
PRCode = PR.PRCode,
UpMaterialNoDesc = tt.MaterialName,
StoreAreaType = ESDStaticClass.StoreAreaType.BadStoreArea
};