When I dummy up your code in VS 2019:
private void FrmMain_Shown(object sender, EventArgs epp)
{
var t = (from e in context.T_Att
group e by new { e.Cod_R, e.Cod_C, e.O_Tot } into g
select new
{
Ris = g.Key.Cod_R,
Cli = g.Key.Cod_C,
O_N = g.Sum(pc => pc.O_Tot) * 1236,
O_S = g.Sum(pc => pc.O_Tot).ToString(),
Tot_rec = g.Count()
}).ToList();
}
public class Context
{
public List<foo> T_Att { get; set; } = new List<foo>();
}
public class foo
{
public int Cod_R { get; set; }
public int Cod_C { get; set; }
public int O_Tot{ get; set; }
}
public Context context = new Context();
I get no errors: The chances are that the error is referring to code above the fragment you show, and on;y showing up as the first line of that code because it can't work out what you meant to write.
So start by looking at the lines immediately above this: is there a missing "}" or similar?