Home > DeveloperSection > Forums > Use Multiple Column Group by in LINQ
Norman Reedus
Norman Reedus

Total Post:45

Points:315
Posted on    March-25-2016 11:22 PM

 LINQ LINQ 
Ratings:


 1 Reply(s)
 211  View(s)
Rate this:
We want to use Multiple Column Group by in LINQ.How to use this please help me.


aditya kumar Patel

Total Post:246

Points:1750
Posted on    March-25-2016 11:24 PM

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

namespace ForumMVC.Controllers

{

public class HomeController : Controller

{

forumEntities context = new forumEntities();

public ActionResult Index()

{

var result = from c in context.CUSTOMER.ToList()

group c by new

{

c.CUST_NAME,

c.CUST_ADDRESS,

c.CUST_PHONE,

} into gcs

select new CUSTOMER()

{

CUST_NAME = gcs.Key.CUST_NAME,

CUST_ADDRESS = gcs.Key.CUST_ADDRESS,

CUST_PHONE = gcs.Key.CUST_PHONE,

};

return View();

}

}

}


Don't want to miss updates? Please click the below button!

Follow MindStick