linq查询问题,急
var arrEan13 = CSR.GroupBy(x => new { x.ean13, x.model, x.color });
foreach (var csr in arrEan13)
{
foreach (var csr1 in csr)
{
sb.Append("<tr><td width='150' bgcolor='#fff'>" + csr1.ean13 + "-" + csr1.model + "</td>");
问个问题,这里为什么要用二个foreach?可以简化成一个吗?
------解决方案--------------------
var arrEan13 = CSR.GroupBy(x => new { x.ean13, x.model, x.color });
arrEan13.SelectMany(csr=>scr).ToList().ForEch(csr=>
{
sb.Append("<tr><td width='150' bgcolor='#fff'>" + csr.ean13 + "-" + csr.model + "</td>");
}