日期:2014-05-20 浏览次数:20783 次
var maxids = brandfile.GroupBy(x => x.fid).Select(g => g.Max(x => x.fieldid));
var b = brandfile.Where(x => x.typeid == 2 && maxids.Contains(x => x.fileid));
var result = from n in NewsInfo
join b in brandfile on n.newsid equals b.fid into n1
from n2 in n1.DefaultIfEmpty()
select new
{
NewsInfo = n,
FileName = b.filename
};
var query=from n in db.NewsInfo
let m=db.brandfile.GroupBy(y=>y.fid).Select(g=>g.Max(z=>z.fieldid)
join b in db.brandfile.Where(x=> x.typeid==2 &&
m.Contains(x=>x.fieldid))
on n.newsid equals b.fid into Left
from b in Left.DefalutIfEmpty()
select new {n,FileName=b==null?"":b.FileName};