1

I am using linq query to group by element through one table field, guid.

The problem is that I do not know how to retrieve the object on the view.

Here is my code:

public ActionResult Index2()
{
    List<Imageupload> lists = db.Imageuploads.ToList();
    var a = lists.GroupBy(g => g.guid);

    return View(a);
}

Imageupload is a modal class and Imageuploads is a table in the database.

How can I accomplish that?

Zeeshan Adil
  • 1,765
  • 4
  • 20
  • 40
Kumar Sanu
  • 146
  • 1
  • 10
  • Possible duplicate of [Group by in LINQ](https://stackoverflow.com/questions/7325278/group-by-in-linq) – Igor Sep 12 '18 at 16:53

1 Answers1

0

Try this:

var groupedList = db.Imageuploads
    .GroupBy(u => u.guid)
    .Select(g=> g.ToList())
    .ToList();

Hope this helps

Zeeshan Adil
  • 1,765
  • 4
  • 20
  • 40