# Linq / Lambda

<figure><img src="https://4182918922-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLIxsxy-PG49XtZX5uS%2Fuploads%2Ff1adFL26nVqodZHy8Eqt%2Fimage.png?alt=media&#x26;token=aa70b5d0-246b-4b25-8987-ab725ce48914" alt=""><figcaption></figcaption></figure>

The ToModel method returns a IEnumberble of SitemapNodeModel, ToModel accepted a T of IEnumberable IPublishedcontent.&#x20;

I need to remove ToModel so I wrote the following :&#x20;

```


List<SitemapNodeModel> list = new List<SitemapNodeModel>();

foreach (var child in children)
{
				SitemapNodeModel sitemap = new SitemapNodeModel
				{
					Id = child.Id,
					Name = child.Name,
					DocumentTypeAlias = child.DocumentTypeAlias,
					Url = child.Url,
					UrlName = child.UrlName,
					UpdateDate = child.UpdateDate
				};
				
				list.Add(sitemap);
}
```

This works but it can also be done with Linq and Lambda&#x20;

```
var children = _umbracoWrapper.Descendants(root)
				.Where(x => _umbracoWrapper.GetPropertyValue<bool>(x, "metaSitemap"))
				.Select(child => new SitemapNodeModel
				{
					Id = child.Id,
					Name = child.Name,
					DocumentTypeAlias = child.DocumentTypeAlias,
					Url = child.Url,
					UrlName = child.UrlName,
					UpdateDate = child.UpdateDate
				}).ToList();



var umbracoNodes = new List<SitemapNodeModel>(children);
```
