Fixes n+1 queries on template repository

This commit is contained in:
Shannon
2014-09-02 12:47:46 +10:00
parent c76d09c9b0
commit 42fe4c77f6
2 changed files with 59 additions and 61 deletions

View File

@@ -461,8 +461,9 @@ namespace Umbraco.Web.Editors
{
//TODO: Need to check for Object types that support hierarchic here, some might not.
return Services.EntityService.GetChildren(id, objectType.Value).Select(Mapper.Map<EntityBasic>)
.WhereNotNull();
return Services.EntityService.GetChildren(id, objectType.Value)
.WhereNotNull()
.Select(Mapper.Map<EntityBasic>);
}
//now we need to convert the unknown ones
switch (entityType)
@@ -483,9 +484,11 @@ namespace Umbraco.Web.Editors
{
//TODO: Need to check for Object types that support hierarchic here, some might not.
var ids = Services.EntityService.Get(id).Path.Split(',').Select(int.Parse);
return ids.Select(m => Mapper.Map<EntityBasic>(Services.EntityService.Get(m, objectType.Value)))
.WhereNotNull();
var ids = Services.EntityService.Get(id).Path.Split(',').Select(int.Parse).Distinct().ToArray();
return Services.EntityService.GetAll(objectType.Value, ids)
.WhereNotNull()
.Select(Mapper.Map<EntityBasic>);
}
//now we need to convert the unknown ones
switch (entityType)