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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:54:18+00:00 2026-06-02T03:54:18+00:00

I have a rest service which has a list of Groups each group has

  • 0

I have a rest service which has a list of Groups each group has a GroupName and on my client side I am trying to add those GroupName’s to a list of variable groupbox’s (number of groupboxes depends on how many GroupNames there is in my rest Group service) can anyone help with the code?:

        string uriGroups = "http://localhost:8000/Service/Group";
        XDocument xDoc = XDocument.Load(uriGroups);
        var groups = xDoc.Descendants("Group")
        .Select(n => new
        {
            GroupBox groupbox = new GroupBox();
            groupbox.Header = String.Format("Group #{0}", n.Element("GroupName");
            groupbox.Width = 100;
            groupbox.Height = 100;
            groupbox.Margin = new Thickness(2);

            StackPanel stackPanel = new StackPanel();
            stackPanel.Children.Add(groupbox);
            stackPanel.Margin = new Thickness(10);

            MainArea.Children.Add(stackPanel);
        }

This isnt correct I am just stuck on how to do it.

EDIT:

    public Reports()
    {
        InitializeComponent();

        string uriGroups = "http://localhost:8000/Service/Group";
        XDocument xDoc = XDocument.Load(uriGroups);
        foreach(var node in xDoc.Descendants("Group"))
        {

            GroupBox groupbox = new GroupBox();
            groupbox.Header = String.Format("Group #{0}", node.Element("Name")); 
            groupbox.Width = 100;
            groupbox.Height = 100;
            groupbox.Margin = new Thickness(2);

            StackPanel stackPanel = new StackPanel();
            stackPanel.Children.Add(groupbox);
            stackPanel.Margin = new Thickness(10);

            MainArea.Children.Add(stackPanel);
        }

    }
    public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
    {
        foreach (var item in enumerable)
            action(item);

        return enumerable;
    }
  • 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-02T03:54:19+00:00Added an answer on June 2, 2026 at 3:54 am

    1) You shouldn’t be using the LINQ Select extension to iterate over the collection and do something; it should only be used to transform the element into a new form. If you want to do something like this, either just use a foreach statement, or make a new LINQ extension to work on the enumerable like so:

      public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
      {
           foreach(var item in enumerable)
               action(item);
    
           return enumerable;
      }
    

    2) The above code shouldn’t compile because it’s syntactically broken. What you’re attempting to do is make a new anonymous type (the new { }). Since you’re not making properties on this object, and instead trying to execute random lines of code (which is not allowed), this is not valid. When making an anonymous type, you would do something like this:

     Enumerable.Range(0, 10).Select(x => new { Number = x });
     // Creates a series of 10 objects with a Number property
    

    3) It sounds like you just need to refactor your code to the appropriate code to get this done. I’m not seeing the particular problem you are having, other than the non compiling part.

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

Sidebar

Related Questions

Hi I have a rest service which has a list of students each student
I have a Jersey REST service which has endpoints that can return either application/xml
So I have wcf rest service which succesfuly runs from a console app, if
I have a REST service for which I have a WADL file. I want
I have a REST service consumed by a .Net WCF client. When an error
I have a WCF REST Service which accepts a JSON string One of the
I have a simple WCF4 REST service which is working fine when using a
I have a rest service which is called in front end using getjson and
Is it possible to create a WCF REST 4.0 service which has two endpoints
I have a servelet which can take a request from either a rest service

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.