2
I am trying to return fields after a merge between collections, but am getting the following error:
foreach statement cannot Operate on variables of type 'Anonymoustype#1' because 'Anonymoustype#1' does not contain a public Definition for 'Getenumerator'
var lst = from p in Produto.produtos
        join c in Produto.categorias
        on p.IdCategoria equals c.IdCategoria
        group p by new { c.IdCategoria, c.Categoria }
            into g
            orderby g.Key.Categoria
            select new { ID = g.Key.IdCategoria, CategoriaNome = g.Key.Categoria, TotalItem = g.Count() };
foreach (var categ in lst)
{
    Console.WriteLine("ID: {0}, Categoria: {1}, Total Item: {2}", categ.ID, categ.CategoriaNome, categ.TotalItem);
    foreach (var item in categ)
    {
        Console.WriteLine("\t\tID: {0}, Produto: {1}", item.IdProduto, item.Produto); <b>// Linha com o Erro</b>
    }
}
I have improved my answer. See now if it suits you.
– Leonel Sanches da Silva