Use Multiple Column Group by in LINQ

Total Post:45

Points:315
LINQ 
 813  View(s)
Ratings:
Rate this:
We want to use Multiple Column Group by in LINQ.How to use this please help me.
  1. Post:279

    Points:1987
    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();

    }

    }

    }

      Modified On Apr-11-2018 03:22:32 AM

Answer

NEWSLETTER

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