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'm looking to find a nice way to convert a list of IPublishedContent objects to their strongly typed ContentModel equivalent but I can't figure it out.
The code I would usually use would be something like:
IList<IPublishedContent> courses = Model.Content.Descendents().Where(x => x.DocumentTypeAlias == "course");
What I'd like to do is end up with the left hand side looking something like:
IList<ContentModels.Course> courses = Model.Content etc etc
Is this possible to do without putting using a mapper?
Ahem. Never mind I was just being a little thick as I've done this a million times in a non Umbraco environment. Here's my solution:
IList<ContentModels.Course> courses = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "course").Select(x => (ContentModels.Course)x).ToList();
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
List of IPublishedContent to ContentModel
Hi,
I'm looking to find a nice way to convert a list of IPublishedContent objects to their strongly typed ContentModel equivalent but I can't figure it out.
The code I would usually use would be something like:
What I'd like to do is end up with the left hand side looking something like:
Is this possible to do without putting using a mapper?
Ahem. Never mind I was just being a little thick as I've done this a million times in a non Umbraco environment. Here's my solution:
is working on a reply...