From 58ef655f8ecc9f23a07e90b811688705322857f5 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 22 Sep 2011 17:56:45 -0700 Subject: [PATCH] #18131: Fixing Aggregate fetching mode for to-many relationships Work Item: 18131 --HG-- branch : 1.x --- .../Orchard.Tags/Controllers/HomeController.cs | 14 +++++++------- src/Orchard/Data/Conventions/AggregateAttribute.cs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Controllers/HomeController.cs b/src/Orchard.Web/Modules/Orchard.Tags/Controllers/HomeController.cs index 63cff0658..4e120966e 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Controllers/HomeController.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Controllers/HomeController.cs @@ -16,7 +16,6 @@ namespace Orchard.Tags.Controllers { private readonly ITagService _tagService; private readonly IContentManager _contentManager; private readonly ISiteService _siteService; - private readonly dynamic _shapeFactory; public HomeController( ITagService tagService, @@ -26,12 +25,13 @@ namespace Orchard.Tags.Controllers { _tagService = tagService; _contentManager = contentManager; _siteService = siteService; - _shapeFactory = shapeFactory; + Shape = shapeFactory; T = NullLocalizer.Instance; } public ILogger Logger { get; set; } public Localizer T { get; set; } + public dynamic Shape { get; set; } public ActionResult Index() { var tags = _tagService.GetTags(); @@ -48,17 +48,17 @@ namespace Orchard.Tags.Controllers { return RedirectToAction("Index"); } - var taggedItems = _tagService.GetTaggedContentItems(tag.Id, pager.GetStartIndex(), pager.PageSize) - .Select(item => _contentManager.BuildDisplay(item, "Summary")); + var taggedItems = _tagService.GetTaggedContentItems(tag.Id, pager.GetStartIndex(), pager.PageSize).ToList(); + var tagShapes = taggedItems.Select(item => _contentManager.BuildDisplay(item, "Summary")); - var list = _shapeFactory.List(); - list.AddRange(taggedItems); + var list = Shape.List(); + list.AddRange(tagShapes); var totalItemCount = _tagService.GetTaggedContentItemCount(tag.Id); var viewModel = new TagsSearchViewModel { TagName = tag.TagName, List = list, - Pager = _shapeFactory.Pager(pager).TotalItemCount(totalItemCount) + Pager = Shape.Pager(pager).TotalItemCount(totalItemCount) }; return View(viewModel); diff --git a/src/Orchard/Data/Conventions/AggregateAttribute.cs b/src/Orchard/Data/Conventions/AggregateAttribute.cs index 5747b6fa0..ffdde0519 100644 --- a/src/Orchard/Data/Conventions/AggregateAttribute.cs +++ b/src/Orchard/Data/Conventions/AggregateAttribute.cs @@ -26,9 +26,9 @@ namespace Orchard.Data.Conventions criteria.Expect(x => x.Property != null && x.Property.IsDefined(typeof(AggregateAttribute), false)); } - public void Apply(IOneToManyCollectionInstance instance) + public void Apply(IOneToManyCollectionInstance instance) { - instance.Fetch.Join(); + instance.Fetch.Select(); } public void Accept(IAcceptanceCriteria criteria)