0
var query = context.headerItems
            .Where(header => header.headerColumn1 != false)
            .Where(item => item.itemColumn1 != null)
            .Select(header => new {
                //Only columns from header table in here
            })
            .ToList()
            .Select(header => new context.header{
                //Only columns from header table in here
            });
return query.ToList();

headerItems are join between header and items.

How do I group by all the selected columns\properties of header?

Pop
  • 525
  • 1
  • 7
  • 22
  • Can you show the definition of `context.headerItems`? – Rafalon Apr 12 '18 at 08:32
  • Possible duplicate with : https://stackoverflow.com/questions/7325278/group-by-in-linq – dtlvd Apr 12 '18 at 08:36
  • @Rafalon `context.headerItems` consist all columns from `header` and some columns from `items`. – Pop Apr 12 '18 at 08:39
  • @Pop yeah cool, but I don't know what is `header` and what is `items` and what is *some columns*. Please understand that people **can't see your screen**. Also note that you are using `.ToList()` twice – Rafalon Apr 12 '18 at 08:50

1 Answers1

1

If you want to group all columns and don't need to calculate count or total, you can simply use distinct that would also give the same result.

Pelin
  • 936
  • 5
  • 12