linq之左连接 + group by

 var list = from item in
                    (from s in _sysBll.GetList(s => s.ParamID == "TraSchType" && s.ParamCode != null)
                    join t in data on s.ParamCode equals t.TraSchType into tmp
                    from f in tmp.DefaultIfEmpty()
                    select new
                    {
                        value = tmp.Count(),
                        name = s.ParamDescn,
                        ParamCode = s.ParamCode
                    })
                group item by item.ParamCode into query
                select new
                {
                    value = query.Max(m => m.value),
                    name = query.Max(m => m.name)
                };

猜你喜欢

转载自www.cnblogs.com/xiaonangua/p/9173470.html