MVC3 JSON Error

I was working on a MVC3 project with jqGrid using JSON.  The data was created using EF4 Code First.  Took me a while to hook up the grid and actually having it post back to the server to retrieve the JSON.  I was having issues with my int ID column not formatting to JSON. 

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

StackOverflow had some responses to use

SqlFunctions.StringConvert((double)products.ProductID)

Then I received a different error

The specified method 'System.String StringConvert(System.Nullable`1[System.Double])' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression.

What I ended up doing is creating a list of the products and then looping through them

var products = from product in db.Products
               select product;
              
var prodList = products.ToList();
 

 

 

Print | posted on Tuesday, May 24, 2011 6:24 PM