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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:40:39+00:00 2026-06-01T22:40:39+00:00

I’m looking for a LINQ delete method for this: <ArrayOfGroup> <Group> <GroupName>c</GroupName> <StudentList> <Student>

  • 0

I’m looking for a LINQ delete method for this:

<ArrayOfGroup>
    <Group>
        <GroupName>c</GroupName>
        <StudentList>
             <Student>
                 <TimeAdded>0001-01-01T00:00:00</TimeAdded> // trying to delete from here
                 <StudentID>1</StudentID>
                 <FirstName>a</FirstName>
                 <LastName>b</LastName> // to here
                 <StudentGroup/>
             </Student>
        </StudentList>
    </Group>
</ArrayOfGroup>

For some reason when I delete it this way:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] 
public class Service : IService
{
    List<Student> students = new List<Student>();
    List<Group> Groups = new List<Group>();
    public void removeStudent(string studentID)
    {
        students.Remove(students.Find(f => f.StudentID.Equals(studentID)));
        //var result = students.Where(n => String.Equals(n.StudentID, studentID)).FirstOrDefault();
        //if (result == null)
        //{
        //    result.StudentGroup.Remove(StudentList.Student.Find(f => f.StudentID.Equals(studentID)));
        //}
        // students.RemoveAll(f => f.StudentID.Equals(studentID)); also tryed this
    }

It doesn’t remove it from the Student List/ student area of my ArrayOfGroup, so I am fed up trying to solve why it isn’t deleting and just trying to find a new way to delete it along with the original records. I feel like a criminal for doing this but if anyone can help would be much appreciated.

My Data Contracts looks like this:

[DataContract(Name="Student")]
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; }

    [DataMember(Name = "TimeAdded")]
    public DateTime TimeAdded;

    public string TimeAddedString
    {
        get
        {
            return this.TimeAdded.ToString("dd/MM/yyyy hh:mm:ss");
        }
    }

    public List<Group> StudentGroup { get; set; }
}

[DataContract(Name = "Group")]
public class Group
{
    public Group() 
    {
        StudentList = new List<Student>();
    }

    [DataMember(Name = "GroupName")]
    public string GroupName { get; set; }

    public List<Student> StudentList { get; set; }
}

This is how a student is added to a group if it helps?

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.StudentList.Add(new Student() { StudentID = studentID, FirstName = firstName, LastName = lastName });
    }
    if (result1 != null)
    {
        result1.StudentGroup.Add(new Group() { GroupName = group });
    }
}  
  • 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-01T22:40:40+00:00Added an answer on June 1, 2026 at 10:40 pm

    You can use the Remove method on the List<T> object which takes a predicate like so:

    students.RemoveAll(s => s.StudentId == 5);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:

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.