Linq的多列GroupBy

多列(Multiple Columns)
var categories =
from p in db.Products
group p by new
{
p.CategoryID,
p.SupplierID
}
into g
select new
{
g.Key,
g
};语句描述:使用Group By按CategoryID和SupplierID将产品分组。

说明:既按产品的分类,又按供应商分类。在by后面,new出来一个匿名类。这里,Key其实质是一个类的对象,Key包含两个Property:CategoryID、SupplierID。用g.Key.CategoryID可以遍历CategoryID的值。

9 comments

  1. Milan Toniatti 说道:

    I just want to say I am newbie to weblog and seriously enjoyed you’re blog site. Most likely I’m going to bookmark your website . You absolutely have perfect well written articles. Cheers for revealing your website page.

  2. Allan Furer 说道:

    Good write-up. I am a normal visitor of your site and appreciate you taking the time to maintain the nice site. I will be a regular visitor for a really long time.

  3. Lovie Farzan 说道:

    I am truly happy to glance at this weblog posts which consists of plenty of helpful information, thanks for providing these information.

  4. Enrique Kuamoo 说道:

    I and my colleagues watch the soccer game clips at YouTube always, for the reason that they have in pleasant quality.

  5. Tyrell Grebe 说道:

    I’d should verify with you here. Which is not something I often do! I take pleasure in studying a publish that may make people think. Additionally, thanks for permitting me to comment!

  6. Geoffrey Liefer 说道:

    If you are going for finest contents like myself, just visit this web page all the time as it provides quality contents, thanks

  7. Eric Napihaa 说道:

    All right you are right, in fact PHP is a open source and its assist we can take free from any discussion board or web page as it happens here at this website.

发表评论

电子邮件地址不会被公开。