Querying Related Dynamic Content Modules

Posted by Community Admin on 04-Aug-2018 04:30

Querying Related Dynamic Content Modules

All Replies

Posted by Community Admin on 14-Feb-2014 00:00

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:
Services

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);
02. 
03.var list = new List<Guid>();
04.list.Add(serviceGuid);
05.Guid[] guidList = list.ToArray();
06. 
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");
10. 
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.

Thanks!
George

Posted by Community Admin on 17-Feb-2014 00:00

George,

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

This thread is closed