From 6cfb864055d3f6222d550fb3474fd86bb906e919 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 28 Oct 2013 11:23:09 +1100 Subject: [PATCH 1/2] Fixes DataTypeDefinitionRepository to properly delete a data type including it's pre-values --- .../Persistence/Repositories/DataTypeDefinitionRepository.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs index 7abcc8e4b0..7cd7069751 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs @@ -204,6 +204,9 @@ namespace Umbraco.Core.Persistence.Repositories Database.Delete("WHERE id = @Id", new { Id = dto.Id }); } + //Delete the pre-values + Database.Delete("WHERE datatypeNodeId = @Id", new {Id = entity.Id}); + //Delete Content specific data Database.Delete("WHERE nodeId = @Id", new { Id = entity.Id }); From 49d5791825bfb4293e9daafdb378cc463e49aa5f Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 28 Oct 2013 12:35:50 +1100 Subject: [PATCH 2/2] Adds DescendantsOrSelf extensions on ienumerable to published content extensions --- src/Umbraco.Web/PublishedContentExtensions.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 8de72a48bb..b4d07b8baa 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -1065,6 +1065,35 @@ namespace Umbraco.Web #region Axes: descendants, descendants-or-self + /// + /// Returns all DescendantsOrSelf of all content referenced + /// + /// + /// + /// + /// + /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// + public static IEnumerable DescendantsOrSelf(this IEnumerable parentNodes, string docTypeAlias) + { + return parentNodes.SelectMany(x => x.DescendantsOrSelf(docTypeAlias)); + } + + /// + /// Returns all DescendantsOrSelf of all content referenced + /// + /// + /// + /// + /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// + public static IEnumerable DescendantsOrSelf(this IEnumerable parentNodes) + where T : class, IPublishedContent + { + return parentNodes.SelectMany(x => x.DescendantsOrSelf()); + } + + // as per XPath 1.0 specs §2.2, // - the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus // the descendant axis never contains attribute or namespace nodes.