More in this section

Forums / Developing with Sitefinity / Querying Related Dynamic Content Modules

Querying Related Dynamic Content Modules

2 posts, 0 answered
  1. George
    George avatar
    17 posts
    16 Jan 2014
    14 Feb 2014
    Link to this post
    I've set up two Dynamic Content Modules and successfully linked one to the other in the backend.  The problem I am having is that I am trying to query the values of one from the other.  The example is as follows:

    Module One:
    Business Area -> Business Unit

    Module Two:

    So Business Unit has an Array of Guid related to Services.  I've created a Widget where you can click on the service and it would load the service information, but now I want to show all the business units in the service.  I've had to do it this way because I'll be displaying all Units in an Area as well and suspect they may have a Unit in multiple service areas knowing how users like to change things :)

    So are there any suggestions on how I can retrieve these?  I thought I would start with the Page Guid but what I really want is the Guid of the Service that was passed to the page and then to be able to run a Linq query using that.  What I've got so far throws an error of:

    Database mapped field uses different type 'System.Guid[]'.
    Parameter name: methodCallExpression
    Actual value was re-d.FieldValue("Service").

    Which was generated from

    01.var serviceGuid = new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key);
    03.var list = new List<Guid>();
    05.Guid[] guidList = list.ToArray();
    07.DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
    08.Type serviceType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Services.Service");
    09.Type businessUnitType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.BusinessAreas.BusinessUnit");
    11.// This is how we get the resource items through filtering
    12.myFilteredCollection = dynamicModuleManager.GetDataItems(businessUnitType)
    13.                                               .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true)
    14.                                               .Where(d => d.GetValue<TrackedList<Guid>>("Service").Contains(guidList))

    Would love any hints as to where I should be looking.  I feel like I've hit the point of reading the same five posts continuously.  My GoogleFoo is failing me.

  2. Tim
    Tim avatar
    258 posts
    22 Jun 2011
    17 Feb 2014 in reply to George
    Link to this post

    If you're still looking for some hints. Here's some code I used a while back to accomplish something like that.
2 posts, 0 answered