Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Children

Dave Greasley edited this page Jul 12, 2015 · 5 revisions

All Concrete Models have a Children property which is an IEnumerable<IPublishedContent> by default. If there are no children this will just return an empty List.

However, if you have only specified 1 'Allowed child node types' for a given Content Type then Concrete will work out that the children property should be typed to the allowed type.

For example, in the demo site in the repo you will find a BlogPostRepository class that represents the BlogPostRepository Content Type. The only allowed child type is a BlogPost so the BlogPostRepository has its children property defined like this:

	private IEnumerable<BlogPost> _children = null;
	public IEnumerable<BlogPost> Children
	{
		get
		{
			if (_children == null)
			{
				_children = this.Content.Children.Select(x => new BlogPost(x));
			}

			return _children;
		}
	}

This lazy loads the Children ensuring that we only create the child objects if we call the property.