如何按linq中新类的选定列\属性进行分组?

时间:2018-04-12 08:15:58

标签: c# linq .net-4.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();

headerItemsheaderitems之间加入。

如何按标题的所有选定列\属性进行分组?

1 个答案:

答案 0 :(得分:1)

如果您想对所有列进行分组而不需要计算计数或总数,则可以使用distinct来提供相同的结果。