0

am accessing a class from my webservice as

[WebMethod(EnableSession = true)]
    public string fetchAbsentees(string date)
    {
        string data = string.Empty;

        StudentAttendances students = new StudentAttendances(date);

        SearchStudents fetchStudents =new SearchStudents(students);

            data = jsonSerialize.Serialize(fetchStudents);
        }
        return data; 
    }

when I execute this code am getting the values from the StudentAttendance class, I have StudentId property along with attendancestatus, date etc in the StudentAttendance class....

in the SearchStudentClass I have a constructor with one parameter(to accept the StudentId), my question is how can I get the StudentId alone from students and pass it to SearchStudents........can anyone help me here

1 Answer 1

1

To get a list of ids from students using Linq

students.Select(student => student.StudentId);

This will return an IEnumerable<YourIDType>. If that's what you're passing to SearchStudents().

Above, you mention that SearchStudents accepts a single StudentId, so in that case you'd need to iterate over each of the students returned by StudentAttendances(date).

I don't know what your SearchStudents class looks like, nor what is returned by StudentAttendances(date) but you could iterate over each of the students returned by the latter, pass it in to the former, and aggregate the results before serializing to JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.