简体   繁体   中英

How to group by the selected columns\properties of new class in linq?

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?

如果要对所有列进行分组,而无需计算计数或总数,则可以简单地使用distinct ,它也可以得出相同的结果。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM