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

  • Home
  • SEARCH
  • 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 9050971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:47:20+00:00 2026-06-16T12:47:20+00:00

In the following class using System; namespace Beverati.Repository.ViewModel { [Serializable] public class CollectionItem :

  • 0

In the following class

using System;

namespace Beverati.Repository.ViewModel
{

[Serializable]
public class CollectionItem : EditableEntityBase
{

public CollectionItem() {}

private int? _quantity;
private string _retailValue;
private string _currencyName;

public int? quantity
{
  get { return this._quantity ?? NULL_INTEGER; }
  set { this._quantity = value; }
}

public string retailValue
{
  get { return this._retailValue ?? String.Empty; }
  set { this._retailValue = value; }
}

public string currencyName
{
  get { return this._currencyName ?? String.Empty; }
  set { this._currencyName = value; }
}

}
}

returned in this controller action

public IEnumerable<Repository.ViewModel.CollectionItem> GetAll()

produces this JSON output with MVC2 the JSON output like this

{
  quantity:2
  retailValue: 50.00
  currencyName: USD
}

However, when I installed MVC4 the JSON returned looks like this

{
  _quantity:2
  _retailValue: 50.00
  _currencyName: USD
}

All the property names have an underscore prefix. Why is the underscore being used and what should be done to have the public property names returned in the JSON?

  • 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-16T12:47:22+00:00Added an answer on June 16, 2026 at 12:47 pm

    The [Serializable] attribute is what’s doing it – Assuming you don’t need it for another purpose – remove the attribute and all should be well.

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

Sidebar

Related Questions

Consider the following code: using System; namespace ConsoleApplication2 { class Program { static void
I currently have a class file with the following enumeration: using System; namespace Helper
Using the following Webservice definition using aClientArgs as a complex type: [System.Web.Script.Services.ScriptService] public class
I have the following classes: using System; using System.Windows.Forms; namespace FastEyeControl { public partial
I have created the following class: using System.Windows; using System.Windows.Input; using MyUtils.MyArgParser; namespace MyUtils.MyImplement
Consider the following class in a file MyClass.cs using System; public class MyClass :
I have a model class similar to the following: using System; using System.Collections.Generic; using
I am trying to register the following class using the fluent interface: public class
I have the following class #ifndef Container_H #define Container_H #include <iostream> using namespace std;
I have the following class: using System; using System.Collections; using System.Collections.Generic; using System.Data; using

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.