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 8832209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:28:38+00:00 2026-06-14T08:28:38+00:00

I have some code that returns linq result (I even tried to add ToList()

  • 0

I have some code that returns linq result (I even tried to add ToList())

I see the collection OK

enter image description here

but when I get out of the function body,
another abstraction layer is added

enter image description here

at the end ewhen I return the client the result

it gets:

“{ apps = System.Collections.Generic.List1[\u003c\u003ef__AnonymousType14[System.String,System.String,\u003c\u003ef__AnonymousType0`4[System.String,System.String,System.String,System.String],System.Object]], Status = succeeded }”

How can I serialize the linq result properly?

Update
Beforehand, it used to work without calling JSON()

    public object GetAppsData()
    {

        var appsData = new List<AppData>();
        using (IDataReader dr = DatabaseFactory.CreateDatabase().ExecuteReader("usp_AppsData_GetAll"))
        {

            while (dr.Read())
            {
                appsData.Add(new AppData()
                {
                    AppGuid = (Guid)dr["AppGuid"],
                    AppName = (string)dr["AppName"],
                    ClientAppID = dr["ClientAppID"] == DBNull.Value ? null : (string)dr["ClientAppID"],
                    Url = dr["Url"] == DBNull.Value ? null : (string)dr["Url"],
                    DisplayName = dr["DisplayName"] == DBNull.Value ? null : (string)dr["DisplayName"],
                    AppDesc = dr["AppDesc"] == DBNull.Value ? null : (string)dr["AppDesc"],
                    PrivacyPolicyUrl = dr["PrivacyPolicyUrl"] == DBNull.Value ? null : (string)dr["PrivacyPolicyUrl"],
                    TermsOfUseUrl = dr["TermsOfUseUrl"] == DBNull.Value ? null : (string)dr["TermsOfUseUrl"],
                    //Platform = dr["Platform"] == DBNull.Value ? null : (string)dr["Platform"],
                    //MaxVersion = dr["MaxVersion"] == DBNull.Value ? null : (string)dr["MaxVersion"],
                    LocalizationKey = dr["LocalizationKey"] == DBNull.Value ? null : (string)dr["LocalizationKey"],
                    Compatibility = dr["Compatibility"] == DBNull.Value ? null : jss.Deserialize<object>((string)dr["Compatibility"])

                });

            }
        }

        var appsDataJson = appsData.Select(GenerateAppsDataClientResponse);

        return new { apps = appsDataJson, Status = "succeeded" };
    }



    private object GenerateAppsDataClientResponse(AppData a)
    {
        object result;
        if (a.Compatibility == null)
        {
            result = new
            {
                id = a.ClientAppID,
                url = a.Url,
                optionsDialog = new
                {
                    displayName = a.DisplayName,
                    appDesc = a.AppDesc,
                    privacyPolicyUrl = a.PrivacyPolicyUrl,
                    termsOfUseUrl = a.TermsOfUseUrl
                }
            };
        }
        else
        {
            // this line throws NullReferenceException
            result = new
            {
                id = a.ClientAppID,
                url = a.Url,
                optionsDialog = new
                {
                    displayName = a.DisplayName,
                    appDesc = a.AppDesc,
                    privacyPolicyUrl = a.PrivacyPolicyUrl,
                    termsOfUseUrl = a.TermsOfUseUrl
                },
                compatibility = a.Compatibility
            };
        }
        return result;
    }
}

and

    [HttpGet]
    public ActionResult GetAppsData()
    {
        try
        {
           AppsDataManager appsData = new AppsDataManager();
           object adr =  appsData.GetAppsData();
           return this.JsonpOptional(adr);
        }
        catch (Exception ex)
        {
            Log.Application.Error("ClientDataController.GetSettings", ex);
            return this.JsonpOptional(new { Status = "failed", Reason = ex.Message });
        }
    }
  • 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-14T08:28:39+00:00Added an answer on June 14, 2026 at 8:28 am

    The cryptic datatype you see in the debugger is just the classname of the anonymous class you return with the new keyword.

    Your main problem is, that you have to return a JsonResult and not the plain object. And don’t forget to specify JsonRequestBehavior.AllowGet. Otherwise you will get an exception when returning JSON Data to a HTTP GET request:

    return Json(new { apps = appsDataJson, Status = "succeeded" },
                     JsonRequestBehavior.AllowGet);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that looks like this: foreach(var obj in collection) { try
I have some code that is supposed to return an NSString. Instead it is
I have some code that does MemoryStream ms = new MemoryStream(); ... return Image.FromStream(ms);
I’m after some C# code that will have the following methods that will return
I have some code that will change the background color of a specific label
I have some code that generates Visio masters for me, and some masters have
I have some code that causes the box2d physics simulation to stutter forever after
I have some code that runs a model in a loop. Each iteration of
I have some code that shows results in a table Right now it will
I have some code that uses the SQL Server 2005 SMO objects to backup

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.