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?
Try this:
var groupedList = db.Imageuploads
.GroupBy(u => u.guid)
.Select(g=> g.ToList())
.ToList();
Hope this helps