USE MULTIPLE COLUMN GROUP BY IN LINQ

Norman Reedus

Total Post:45

Points:315
Posted by  Norman Reedus
LINQ 
 572  View(s)
Ratings:
Rate this:
We want to use Multiple Column Group by in LINQ.How to use this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: Use Multiple Column Group by in LINQ

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

    }

    }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!