Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi I want to retrieve a list with the names of the childpages.
The childpages need to be joined, so I would have a string like:
Peter, Patrick, Denise
var instructors = Library.Join(",",school.Descendants("InstructorPage").Where("Visible").Select("Name").ToArray());
I have something like the above but this won't work.
Is there a short way of doing this, or do I need to make a foreach loop for this?
Thanks,
Patrick
i'd say that your Select("Name") isn't working... How about:
var instructors = Library.Join(",", school.Descendants("InstructorPage").Where("Visible").Items.Select(d => d.Name).ToArray());
Cheers,
/Dirk
Hi Dirk,
Thanks, for the response.
I tried that before, but that will throw an exception:
Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
For now I used a different approach:
var names = new List<string>();foreach (var instructor in school.Descendants("InstructorPage").Where("Visible")){ names.Add(instructor.Name);}@String.Join(", ",names.ToArray())
Don't like the solution, so I'll look into this later.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to use Lamda Expression to Select all the names of the children
Hi I want to retrieve a list with the names of the childpages.
The childpages need to be joined, so I would have a string like:
Peter, Patrick, Denise
I have something like the above but this won't work.
Is there a short way of doing this, or do I need to make a foreach loop for this?
Thanks,
Patrick
i'd say that your Select("Name") isn't working... How about:
Cheers,
/Dirk
Hi Dirk,
Thanks, for the response.
I tried that before, but that will throw an exception:
Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
For now I used a different approach:
Don't like the solution, so I'll look into this later.
is working on a reply...