簡體   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();

headerItemsheaderitems之間的header

如何按標題的所有選定列\\屬性分組?

如果要對所有列進行分組,而無需計算計數或總數,則可以簡單地使用distinct ,它也可以得出相同的結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM