码迷,mamicode.com
首页 > 其他好文 > 详细

Linq 多连接及 left join 实例 记录

时间:2016-11-25 12:10:41      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:tun   plist   ast   tostring   text   price   equal   efault   stp   

var retList = from d in mbExList.Cast<MaterialBaseEx>().ToList()
join c in umcList.Cast<ClassifyBaseEx>().ToList() on d.ClsCode equals c.ClsCode
join b in collectItem.Cast<CollectItem>().ToList() on d.Guid equals b.MatID into temp
join e in mlpList.Cast<MaterialLastPrice>().ToList() on d.MatCode equals e.MatCode into tempxx
from tt in temp.DefaultIfEmpty()
from xx in tempxx.DefaultIfEmpty()
where (d.IsPublish.Equals(true)) || tt != null
select new MaterialPriceCollect
{
Guid = Guid.NewGuid().ToString(),
MatCode = d.MatCode,
//Area = areaRec.Text,
PriceType = 1,
State = 2,
MatName = d.MatName==null?"":d.MatName,
Unit = d.MatUnit == null ? "" : d.MatUnit,
MatType = d.MatModel == null ? "" : d.MatModel,
LastPrice = (xx==null || xx.LastPrice == null) ? 0 : xx.LastPrice,
UserId = "_" + userId + ",",
MatId = d.Guid == null ? "" : d.Guid,
IsFrequently = (int)EumIsFrequently.否,
//ReportTime = DateTime.Now,
Weight = (tt==null ||tt.Weight == null) ? 1 : tt.Weight,
//AreaCode = areaRec.Id,
//PeriodNo = objMat.CurPeriodNo,
};

Linq 多连接及 left join 实例 记录

标签:tun   plist   ast   tostring   text   price   equal   efault   stp   

原文地址:http://www.cnblogs.com/xiaoruilin/p/6100785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!