I need to group by Names and to sum all the instance of the name this is my code in the controller:
public class FansController : Controller
{
private dbFan
var result = from f in db.fans
group 1 by f.Name into g
select new { Name = g.Key, Amount = g.Count() };
Now the @model
should currently be:
IEnumerable<dynamic>
. From: view with IEnumerable of object type in MVC: @model IEnumerable<dynamic>
see this
Selecting count in LINQ
And try something like:
var group = (from f in db.fans
group f by a.Name into g
select new { Name = g.Name, Count = g.Count() });