fixes the n+1 queries on content and media type controllers and ensures if there are no ids that the query doesn' texeucte.
This commit is contained in:
@@ -59,7 +59,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
types = Services.ContentTypeService.GetAllContentTypes().ToList();
|
||||
|
||||
//if no allowed root types are set, just return everythibg
|
||||
//if no allowed root types are set, just return everything
|
||||
if(types.Any(x => x.AllowedAsRoot))
|
||||
types = types.Where(x => x.AllowedAsRoot);
|
||||
}
|
||||
@@ -71,9 +71,11 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
types = Services.ContentTypeService.GetAllContentTypes(
|
||||
contentItem.ContentType.AllowedContentTypes.Select(x => x.Id.Value).ToArray())
|
||||
.ToList();
|
||||
var ids = contentItem.ContentType.AllowedContentTypes.Select(x => x.Id.Value).ToArray();
|
||||
|
||||
if (ids.Any() == false) return Enumerable.Empty<ContentTypeBasic>();
|
||||
|
||||
types = Services.ContentTypeService.GetAllContentTypes(ids).ToList();
|
||||
}
|
||||
|
||||
var basics = types.Select(Mapper.Map<IContentType, ContentTypeBasic>).ToList();
|
||||
|
||||
@@ -61,8 +61,11 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
return Services.ContentTypeService.GetAllMediaTypes(
|
||||
contentItem.ContentType.AllowedContentTypes.Select(x => x.Id.Value).ToArray())
|
||||
var ids = contentItem.ContentType.AllowedContentTypes.Select(x => x.Id.Value).ToArray();
|
||||
|
||||
if (ids.Any() == false) return Enumerable.Empty<ContentTypeBasic>();
|
||||
|
||||
return Services.ContentTypeService.GetAllMediaTypes(ids)
|
||||
.Select(Mapper.Map<IMediaType, ContentTypeBasic>);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user