1

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:

enter image description here

Thanks in advance.

1
  • Please post the text of the stack trace. Commented Feb 14, 2012 at 17:20

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.