Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:32:19+00:00 2026-06-02T16:32:19+00:00

A very new programmer to MVC, JSON & LINQ – I have created an

  • 0

A very new programmer to MVC, JSON & LINQ – I have created an ActionResult that returns a JSONResult:

var formhistory = from p in _formsRepository.ReturnedForms
                          where p.DateAdded >= DateTime.Now.Date.AddDays(-15) && p.DateAdded <= DateTime.Now.Date
                          group p by new {p.Centre, p.Form, p.DateAdded}
                          into g
                          select new {
                                         g.Key.Centre,
                                         g.Key.Form,
                                         g.Key.DateAdded,
                                         Total = g.Sum(p => p.Quantity)
                                     };
return Json(formhistory, JsonRequestBehavior.AllowGet);

This gives me a nice JSON result set as follows:

[
  {"Centre":"Centre1","Form":"Advice","DateAdded":"\/Date(1331856000000)\/","Total":1067},
  {"Centre":"Centre1","Form":"Advice","DateAdded":"\/Date(1332460800000)\/","Total":808},
  {"Centre":"Centre1","Form":"Advice","DateAdded":"\/Date(1333062000000)\/","Total":559},
  {"Centre":"Centre1","Form":"Advice","DateAdded":"\/Date(1333666800000)\/","Total":1448}
]

My question is this: I’m trying to manipulate this JSON string so that instead of 2 key/value pairs for “Form” and “Total” I only have 1, i.e. “Form”:”Total”.

I realise this is probably a very basic question, but can anyone point me in the correct direction? (Apart from the door!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:32:20+00:00Added an answer on June 2, 2026 at 4:32 pm
    select new {
       g.Key.Centre,
       //g.Key.Form,
       g.Key.DateAdded,
       Form = g.Sum(p => p.Quantity)
    }
    

    would give you a key “Form” whose value is the former “Total”. Is that what you want?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a very new programmer, I have made a couple basic applications, however
I am a rather new C++ programmer. I have made a very simple game
I am a very new programmer, and I have some trouble with the examples
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Very new to XSL (and XML for that matter), but I need to step
I very new to Python, and fairly new to regex. (I have no Perl
Im very new to all coding including jquery. I though this would have been
I'm a fairly new programmer and very new to web programming and I need
HI I am a new java programmer (very new). What I want to do/test
I'm Delphi programmer and very new to Cocoa. at first I tried this :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.