protected override IContentType PerformGet(int id)
        {
            var contentTypeSql = GetBaseQuery(false);

            contentTypeSql.Where(GetBaseWhereClause(), new { Id = id });

            // The SQL will contain one record for each allowed template, so order to put the default one
            // at the top to populate the default template property correctly.
            contentTypeSql.OrderByDescending <DocumentTypeDto>(x => x.IsDefault);

            var dto = Database.Fetch <DocumentTypeDto, ContentTypeDto, NodeDto>(contentTypeSql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var factory     = new ContentTypeFactory(NodeObjectTypeId);
            var contentType = factory.BuildEntity(dto);

            contentType.AllowedContentTypes          = GetAllowedContentTypeIds(id);
            contentType.PropertyGroups               = GetPropertyGroupCollection(id, contentType.CreateDate, contentType.UpdateDate);
            ((ContentType)contentType).PropertyTypes = GetPropertyTypeCollection(id, contentType.CreateDate, contentType.UpdateDate);

            var templates = Database.Fetch <DocumentTypeDto>("WHERE contentTypeNodeId = @Id", new { Id = id });

            if (templates.Any())
            {
                contentType.AllowedTemplates = templates.Select(template => _templateRepository.Get(template.TemplateNodeId)).ToList();
            }

            var list = Database.Fetch <ContentType2ContentTypeDto>("WHERE childContentTypeId = @Id", new { Id = id });

            foreach (var contentTypeDto in list)
            {
                bool result = contentType.AddContentType(Get(contentTypeDto.ParentId));
                //Do something if adding fails? (Should hopefully not be possible unless someone created a circular reference)
            }

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            ((Entity)contentType).ResetDirtyProperties(false);
            return(contentType);
        }