简体   繁体   English

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

[英]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 . headerItemsheaderitems之间的header

How do I group by all the selected columns\\properties of header? 如何按标题的所有选定列\\属性分组?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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