I have got the following code that produce an image. But I’m getting the an error message.
My code:
public ActionResult Index()
{
eCommerceEntities db = new eCommerceEntities();
var orders = (from c in db.Orders
group c by c.PaymentTypeID into g
select new { PaymentTypeID = g.Key, Number = g.Count() });
var bytes = new Chart(width: 600, height: 400)
.AddTitle("Orders")
.DataBindTable(dataSource: orders, xField: "PaymentTypeID")
.GetBytes("png");
return File(bytes, "image/png");
}
Error Message:
Specified method is not supported.
Stack Trace:

Thanks in advance.
It looks like the chart is trying to enumerate the LINQ query multiple times on one enumerator.
Call
ToList()before passing the data to the chart.