We help IT Professionals succeed at work.
Get Started

convert list to json

maqskywalker asked
Last Modified: 2014-09-03
I'm  working on a C# asp.net mvc 5 application and using Visual Studio 2013.
I'm using database first entity model and Entity Framework 6.

I'm using the Customers and Orders tables from the Northwind database.
My entity model is called northwindEF.edmx and contains a stored procedure called GetCustomerOrders.

Visual Studio  generated a function for my stored procedure called GetCustomerOrders_Result

So right now in my Models folder  of my application along with northwindEF.edmx  I also have a class called NorthwindModel.cs

The code for NorthwindModel.cs looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Objects;

namespace NorthwindSample.Models
    public class NorthwindModel
        // an instance called customerordersdb of the NorthwindEntities
        NorthwindEntities customerordersdb = new NorthwindEntities();

        // a function called GetCustOrders that calls the GetCustomerOrders_Result collection and returns a list
        public List<GetCustomerOrders_Result> GetCustOrders()
            return customerordersdb.GetCustomerOrders().ToList();

Open in new window

So I tried binding that function to a HTML Helper MVC Web Grid in my view and that function works fine.

No I'm trying to bind this function to a jquery Flexigrid  ( http://flexigrid.info )

In order to be able to bind it to flexigrid I have to convert  my list function shown above to a function that returns a json version of my list.   Because I have to feed flexigrid json type.

Anyone know the syntax for a json function that will convert my list function above to json data type?
Watch Question
Distinguished Expert 2017
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE