title: Retrieving Data from LINQ to SQL in JSON format?
body: <p>I have a problem with Serialization of Data from database to JSON format. I'm using WebAPI 2 and Entity Framework 6. I've created with EF a Model. The database and the tables with content are even created. 
  When I use the code below I'm getting an error when I type <a href="http://localhost:54149/api/qr_group" rel="nofollow">http://localhost:54149/api/qr_group</a> .</p>
  
  <p>Controller:</p>
  
  <pre><code>private EfContext db = new EfContext();
  
  // GET api/&lt;controller&gt;
  public IEnumerable&lt;QR_Group&gt; GetGroups()
  {
      var result = from g in db.QR_Groups
                   select g;
      return result.ToList();
  }
  </code></pre>
  
  <p>I don't know how to use Newtonsoft.Json to serialize the table with the content in JSON format.</p>
  
  <p>I've tried the following code instead of the code above:</p>
  
  <pre><code>public IQueryable&lt;QR_Group&gt; GetGroups()
  {
    var groupList = (from g in db.QR_Groups
                     select new
                     {
                       name = g.name,
                       code = g.code
                     }).AsQueryable();
  
    var json = JsonConvert.SerializeObject(groupList);
  
    return json; //error CS0029: Cannot implicitly convert type `string' to `System.Linq.IQueryable&lt;RestApi.Models.QR_Group&gt;'
  }
  </code></pre>
  
  <p>I get the error CS0029.. How can I solve this to return the data in json? As reminder: The QR_Group entity has 3 columns (Id, name, code)</p>