diff --git a/src/Umbraco.Core/Models/IPublishedContent.cs b/src/Umbraco.Core/Models/IPublishedContent.cs
index 213a0e5ed3..6f55bdb413 100644
--- a/src/Umbraco.Core/Models/IPublishedContent.cs
+++ b/src/Umbraco.Core/Models/IPublishedContent.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
namespace Umbraco.Core.Models
{
@@ -10,7 +11,7 @@ namespace Umbraco.Core.Models
///
/// A replacement for INode which needs to occur since INode doesn't contain the document type alias
/// and INode is poorly formatted with mutable properties (i.e. Lists instead of IEnumerable)
- ///
+ ///
public interface IPublishedContent
{
int Id { get; }
diff --git a/src/Umbraco.Tests/EnumerableExtensionsTests.cs b/src/Umbraco.Tests/EnumerableExtensionsTests.cs
index 6a311340b0..ee339b3040 100644
--- a/src/Umbraco.Tests/EnumerableExtensionsTests.cs
+++ b/src/Umbraco.Tests/EnumerableExtensionsTests.cs
@@ -7,16 +7,34 @@ using umbraco.BusinessLogic;
namespace Umbraco.Tests
{
- [TestFixture]
+ [TestFixture]
public class EnumerableExtensionsTests
{
- [Test]
- public void Flatten_List()
- {
- var hierarchy = new TestItem()
- {
- Children = new List()
+ [Test]
+ public void Flatten_List_2()
+ {
+ var hierarchy = new TestItem()
+ {
+ Children = new List()
+ {
+ new TestItem(),
+ new TestItem(),
+ new TestItem()
+ }
+ };
+
+ var flattened = hierarchy.Children.FlattenList(x => x.Children);
+
+ Assert.AreEqual(3, flattened.Count());
+ }
+
+ [Test]
+ public void Flatten_List()
+ {
+ var hierarchy = new TestItem()
+ {
+ Children = new List()
{
new TestItem()
{
@@ -65,12 +83,12 @@ namespace Umbraco.Tests
}
},
}
- };
+ };
- var flattened = hierarchy.Children.FlattenList(x => x.Children);
+ var flattened = hierarchy.Children.FlattenList(x => x.Children);
Assert.AreEqual(10, flattened.Count());
- }
+ }
private class TestItem
{
@@ -78,7 +96,7 @@ namespace Umbraco.Tests
{
Children = Enumerable.Empty();
}
- public IEnumerable Children { get; set; }
+ public IEnumerable Children { get; set; }
}
[Test]
diff --git a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs
index ff618763ac..37d13e1a48 100644
--- a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
@@ -218,6 +219,7 @@ namespace Umbraco.Tests.PublishedContent
}
}
+ [DebuggerDisplay("Content Id: {Id}, Name: {Name}")]
public class PublishedContentWrapper : IPublishedContent, IOwnerCollectionAware
{
protected IPublishedContent WrappedContent { get; private set; }
diff --git a/src/Umbraco.Web/DefaultPublishedMediaStore.cs b/src/Umbraco.Web/DefaultPublishedMediaStore.cs
index ab84aa5f9a..8cce5b80a7 100644
--- a/src/Umbraco.Web/DefaultPublishedMediaStore.cs
+++ b/src/Umbraco.Web/DefaultPublishedMediaStore.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.XPath;
@@ -365,9 +366,17 @@ namespace Umbraco.Web
if (results.Any())
{
- return useLuceneSort
- ? results.Select(ConvertFromSearchResult) //will already be sorted by lucene
- : results.Select(ConvertFromSearchResult).OrderBy(x => x.SortOrder);
+ return useLuceneSort
+ ? results.Select(ConvertFromSearchResult) //will already be sorted by lucene
+ : results.Select(ConvertFromSearchResult).OrderBy(x => x.SortOrder);
+ }
+ else
+ {
+ //if there's no result then return null. Previously we defaulted back to library.GetMedia below
+ //but this will always get called for when we are getting descendents since many items won't have
+ //children and then we are hitting the database again!
+ //So instead we're going to rely on Examine to have the correct results like it should.
+ return Enumerable.Empty();
}
}
catch (FileNotFoundException)
@@ -378,23 +387,27 @@ namespace Umbraco.Web
}
}
+
+ //falling back to get media
+
var media = library.GetMedia(parentId, true);
if (media != null && media.Current != null)
{
+ media.MoveNext();
xpath = media.Current;
}
else
{
- return null;
+ return Enumerable.Empty();
}
}
- //The xpath might be the whole xpath including the current ones ancestors so we need to select the current node
- var item = xpath.Select("//*[@id='" + parentId + "']");
- if (item.Current == null)
- {
- return null;
- }
+ //The xpath might be the whole xpath including the current ones ancestors so we need to select the current node
+ var item = xpath.Select("//*[@id='" + parentId + "']");
+ if (item.Current == null)
+ {
+ return Enumerable.Empty();
+ }
var children = item.Current.SelectChildren(XPathNodeType.Element);
var mediaList = new List();
diff --git a/src/Umbraco.Web/Models/DynamicPublishedContent.cs b/src/Umbraco.Web/Models/DynamicPublishedContent.cs
index fc43675f2b..1b449de5a4 100644
--- a/src/Umbraco.Web/Models/DynamicPublishedContent.cs
+++ b/src/Umbraco.Web/Models/DynamicPublishedContent.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Web;
@@ -20,6 +21,7 @@ namespace Umbraco.Web.Models
///
/// The base dynamic model for views
///
+ [DebuggerDisplay("Content Id: {Id}, Name: {Name}")]
public class DynamicPublishedContent : DynamicObject, IPublishedContent, IOwnerCollectionAware
{
protected internal IPublishedContent PublishedContent { get; private set; }
diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs
index bb45ac12c4..87c1b3c889 100644
--- a/src/Umbraco.Web/Models/PublishedContentBase.cs
+++ b/src/Umbraco.Web/Models/PublishedContentBase.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using Umbraco.Core;
@@ -17,6 +18,7 @@ namespace Umbraco.Web.Models
/// This also ensures that we have an OwnersCollection property so that the IsFirst/IsLast/Index helper methods work
/// when referenced inside the result of a collection. http://issues.umbraco.org/issue/U4-1797
///
+ [DebuggerDisplay("Content Id: {Id}, Name: {Name}")]
public abstract class PublishedContentBase : IPublishedContent, IOwnerCollectionAware
{
private string _url;