/// <summary> /// Returns property types inheritted by base document type. /// </summary> public IList <PropertyType> GetInheritedPropertyTypes(ContentDbContext context) { context.Entry(this).Reference(dt => dt.Base).Load(); if (this.Base == null) { return(new List <PropertyType>()); } else { return(this.Base.AllPropertyTypes(context)); } }
/// <summary> /// Returns property types of this document type including the inheritted property types. /// Items are ordered according to the hierarchy (property types of root first), then by DisplayOrder. /// </summary> public IList <PropertyType> AllPropertyTypes(ContentDbContext context) { // Collect all inherited properties: var allPropertyTypes = this.GetInheritedPropertyTypes(context).ToList(); // Then add owned properties one by one: context.Entry(this).Collection(dt => dt.OwnPropertyTypes).Load(); foreach (var item in this.OwnPropertyTypes.OrderBy(pt => pt.DisplayOrder).ThenBy(pt => pt.Name)) { // Remove overriden properties: allPropertyTypes.RemoveAll(pt => pt.Name == item.Name); // Add the property: allPropertyTypes.Add(item); } // Return result: return(allPropertyTypes); }