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

I am trying to send an object(item) from my Controller to my View as shown below.
C#
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.
Posted
Updated 12-Dec-12 3:35am
v2

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.
C#
rows = (from p in storeDB.Products
where p.ProductID == id
select
new[] { Convert.ToString(p.Id), p.Name,
                           p.Description,p.Category, Convert.ToString(p.Value) };
).ToArray()
};
 
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