日期:2014-05-20 浏览次数:20720 次
select dis.ProductId,pro.ProductName,pho.Photo,SUM(case when dis.MsgContent<>'' or dis.MsgImage<>'' or dis.MsgSound<>'' then 1 else 0 end)msgcount
from Discuss dis,ProductInfo pro,ProductPhoto pho
where dis.ProductId=pro.ID and dis.ProductId=pho.ProductID
group by dis.ProductId,pro.ProductName,pho.Photo
var query = from dis in Discuss
from pro in ProductInfo
from pho in ProductPhoto
where dis.ProductId == pro.ID && dis.ProductId == pho.ProductID
group new { dis, pro, pho } by new { dis.ProductId, pro.ProductName, pho.Photo } into g
select new { Key.dis.ProductId, Key.pro.ProductName, Key.pho.Photo,
msgcount = g.Sum(x => (x.dis.MsgContent <> ""
------解决方案--------------------
x.dis.MsgImage <> ""
------解决方案--------------------
x.dis.MsgSound <> "") ? 1 : 0) };