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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:34:19+00:00 2026-06-01T18:34:19+00:00

So I have an windows form application (client) which displays which groups belong to

  • 0

So I have an windows form application (client) which displays which groups belong to a student.

On the service side this is done like so:

    List<Student> students = new List<Student>();
    List<Group> Groups = new List<Group>();
    public List<Group> GetStudentCollectionByGroup(string anything)
    {

        List<Group> groups = (from g in Groups
                              where
                                  (from t in g.Groupsz where
                                          string.Equals(t.StudentID, anything, StringComparison.CurrentCultureIgnoreCase)
                                       || string.Equals(t.FirstName, anything, StringComparison.CurrentCultureIgnoreCase)
                                       || string.Equals(t.LastName, anything, StringComparison.CurrentCultureIgnoreCase)
                                   select t).Count() > 0
                              select g).ToList();
        return groups;
    }

To add a student to a group I have used this method:

    public void AddStudentToGroup(string group, string studentID, string firstName, string lastName)
    {
        var result = Groups.Where(n => String.Equals(n.GroupName, group)).FirstOrDefault();
        if (result != null)
        {
            result.Groupsz.Add(new Student() { StudentID = studentID });
            result.Groupsz.Add(new Student() { FirstName = firstName });
            result.Groupsz.Add(new Student() { LastName = lastName });
        }
    }  

And my GET method looks like this:

    [OperationContract]
    [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/GetStudentCollectionByGroup/{anything}")]
    List<Group> GetStudentCollectionByGroup(string anything);

The data contracts look like this:

public class Student
{
    public Student()
    {
        StudentGroup = new List<Group>();
    }
    [DataMember(Name = "StudentID")]
    public string StudentID { get; set; }
    [DataMember(Name = "FirstName")]
    public string FirstName { get; set; }
    [DataMember(Name = "LastName")]
    public string LastName { get; set; }
    public List<Group> StudentGroup { get; set; }
}
[DataContract(Name = "Group")]
public class Group
{
    public Group() 
    {
        Groupsz = new List<Student>();
    }
    public string GroupName { get; set; }
    public List<Student> Groupsz { get; set; }
}

Now I have no problem getting the group from my client side when I type in the specific student. But when I type into a different textbox to get the students based on Group nothing is returned? For instance if I type group “A” it should return all the students who belong to that group. Just like how I return a collection of groups who belong to student “B”

  • 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-01T18:34:20+00:00Added an answer on June 1, 2026 at 6:34 pm

    I think I found the problem, not sure why but adding the student to the group and group to the student seems to work. However I could be duplicating records.

      public void AddStudentToGroup(string group, string studentID, string firstName, string lastName)
        {
            var result = Groups.Where(n => String.Equals(n.GroupName, group)).FirstOrDefault();
            var result1 = students.Where(n => String.Equals(n.StudentID, studentID)).FirstOrDefault();
            if (result != null)
            {
                result.Groupsz.Add(new Student() { StudentID = studentID, FirstName = firstName, LastName = lastName });
            }
            if (result1 != null)
            {
                result1.StudentGroup.Add(new Group() { GroupName = group });
            }
    
        }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# Windows Form application that contains a menu with this event:
I will have a client application using a proxy to a WCF Service. This
I have a windows form application that uses a Shared class to house all
I have a Windows Form application built on a data model and a Windows
I have a Windows Form application. Version 1 of my app has been released
I have a Windows form application that's consuming web services over https and is
I have a Windows Form application with a button named loginBtn and a label
I have a C# windows form application (Actually it is a IE toolbar application),
I have a C# Windows Form Application and a live video feed. I need
I have been developing a C# windows form application in XP. It all works

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.