Linq to Sql 左连接查询

 var query = from t0 in context.ExpressSendMaster
join t1 in context.Supplier on t0.SupplierCode equals t1.SupplierCode
join t2 in context.ExpressSendPackageRule on t0.AreaId equals t2.Id into t0_join
from t0_t2 in t0_join.DefaultIfEmpty()
where t0.Id == MasterId
select new ExpressPackageOffLineModel
{
PackWeight = t0.Weight,
SupplierCode = t1.SupplierCode,
SupplierName = t1.Name,
SendDate = t0.SendDate,
OneselfNumber = t0.OneselfNumber,
Memo = t0.Memo,
GroupCheck = t0.AreaCode,
GroupName = t0_t2.NumberType == null ? "" : t0_t2.NumberType,
GroupId = t0_t2.Id == null ? : t0_t2.Id,
LimitWeight = t0_t2.LimitWeight == null ? : t0_t2.LimitWeight
}; if (query.Count() <= )
{
model.HasError = true;
model.ErrorMessage = "错误提示";
return false;
} model.PackWeight = query.First().PackWeight;
model.SupplierCode = query.First().SupplierCode;
model.SupplierName = query.First().SupplierName;
model.SendDate = query.First().SendDate;
model.OneselfNumber = query.First().OneselfNumber;
model.GroupName = query.First().GroupName;
model.Memo = query.First().Memo;
model.GroupCheck = query.First().GroupCheck;
model.GroupId = query.First().GroupId;
model.LimitWeight = query.First().LimitWeight;
上一篇:SSRS报表服务随笔(rdl报表服务)-报表结构与样式


下一篇:HBase 系列(二)—— HBase 系统架构及数据结构