【问题标题】:How to use GroupBy in LINQ? [duplicate]如何在 LINQ 中使用 GroupBy? [复制]
【发布时间】:2014-02-14 16:34:31
【问题描述】:

listProducts 我有一个名为“family”的字段。我想GroupBy这个字段。

var products = from listProducts in repository.All() 
               where (listProducts.Code == "48654")
               select listProducts;`

【问题讨论】:

标签: c# asp.net-mvc linq entity-framework


【解决方案1】:

试试这个,

var products = from listProducts in repository.All()
                where listProducts.Code == "48654"
                group listProducts by listProducts.family into grp
                select grp;

欲了解更多信息,请访问LINQ Group By

【讨论】:

    猜你喜欢
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    • 2016-12-11
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多