Please go over GROUPING SETS first.
var query = DbContext.Set<SalesSummary>()
.Query((SalesSummary alias) =>
{
var salesSummary = GetSalesSummaryTable();
var result = SELECT<SalesSummary>(salesSummary.Brand.@as(alias.Brand),
salesSummary.Category.@as(alias.Category),
SUM(salesSummary.Sales).@as(alias.Sales));
FROM(salesSummary);
GROUP(BY(CUBE(salesSummary.Brand, salesSummary.Category)));
return result;
});
foreach (var salesSummary in query.Take(3))
Console.WriteLine((salesSummary.Brand, salesSummary.Category, salesSummary.Sales));
Replace CUBE
with ROLLUP
above and run!