public ActionResult Index()
{
var Data = new NorthwindDataContext().OrdersViews.GroupBy(g => new { g.EmployeeID, g.OrderID })
.Select(s => new Models.OrdersView
{
EmployeeID = s.Key.EmployeeID,
OrderID = s.Key.OrderID,
Freight = s.Sum(d => d.Freight)
}).OrderBy(o => o.EmployeeID);
ViewBag.dataSource = Data.AsEnumerable().ToList();//convert to list
return View();
} |