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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:51:56+00:00 2026-06-11T05:51:56+00:00

Okay, so here’s my question. I’m working with a saveresult from the Salesforce API,

  • 0

Okay, so here’s my question. I’m working with a saveresult from the Salesforce API, and I am learning LINQ. It may not be the best thing to use here, I don’t know, but this is what I’m trying to do, just more eloquently.

BTW, here’s the saveresult[] class shrunk down to definitions:

public partial class SaveResult {

    private Error[] errorsField;
    private string idField;
    private bool successField;

    [System.Xml.Serialization.XmlElementAttribute("errors")]
    public Error[] errors

    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public string id

    public bool success 
}

And here’s waht I’m trying to do. Check for errors, return them if there are any in any of the returned save results, or return null if no errors.

string errors = null;
        foreach (SaveResult s in saved)
        {
            if (s.success) continue;
            else
            {
                foreach (Error e in s.errors)
                {
                    errors += String.Format("Errors on object: {0}. Error Code is: {1}. Error Message: {2}",
                                            s.id,e.statusCode.ToString(),e.message);
                }
            }
        }

So far I have:

return saved
   .Select(i => i.errors
      .Select(j => new { j.statusCode, j.message })
      .Distinct()
      .ToList()
      ).ToString();

I’m pretty sure I will need an anonymous function in there to evaluate i for errors before I go on.

Anyway, that’s it. Thanks for the help (or the links pointing me to help!)

  • 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-11T05:51:58+00:00Added an answer on June 11, 2026 at 5:51 am

    Using the query syntax:

    return string.Join("",
        from s in saved
        where ! s.Success
        from e in s.Errors
        select string.Format(
            "Errors on object: {0}. Error Code is: {1}. Error Message: {2}",
            s.id, e.statusCode);
    

    This is translated to a SelectMany behind the scenes.

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

Sidebar

Related Questions

Okay so here's the thing: I have a linq query which loads approx. 1000
Okay, here is my situation: I'm looking for the best design approach. I'm working
Okay the title may not justify what I'm trying to do here but dont
Okay so here is the deal. As the question states, I'm trying to POST
Okay so here's my algorithm for finding a Cut in a graph (I'm not
Okay this is definitely a n00b question but here goes. The way I understand
Okay here is a softball beginner WPF question. By default the background of the
Okay here's the situation.... I'm working on a my business website. There will be
Okay, here's my problem. The system I'm working with uses objects called Areas to
Okay here's the damned thing: - (void)setMinimumNumberOfSides:(NSNumber *)newMinimumNumberOfSides { if (newMinimumNumberOfSides != minimumNumberOfSides) {

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.