Click here to Skip to main content
15,745,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am trying to send an object(item) from my Controller to my View as shown below.
var item = new
      rows = (from p in storeDB.Products
              where p.ProductID == id
              select p).ToArray()
   return Json(item, JsonRequestBehavior.AllowGet);

But whenever I try to do so the object is never returned to the view instead it goes into an infinite loop inside MyDatabase.Designer.cs file. Pls help.
Updated 12-Dec-12 3:35am

1 solution

Try something like this:
don't select p select a new[] and make sure that all items are string, if not convert them.
rows = (from p in storeDB.Products
where p.ProductID == id
new[] { Convert.ToString(p.Id), p.Name,
                           p.Description,p.Category, Convert.ToString(p.Value) };
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900