Getting related data and childs dinamically in code

Posted by Community Admin on 05-Aug-2018 08:25

Getting related data and childs dinamically in code

All Replies

Posted by Community Admin on 30-Nov-2015 00:00

Hi,

I have created a content type that has both a child and a related data column. From the sample codes I saw in your site I can see that you need to "hardcode" the columns in order to retrieve the information. 

 

docs.sitefinity.com/example-filter-dynamic-content-items-by-dynamic-field

Is there any way of getting this columns dinamically and then request for each type or is there a way to get the complete object like Lazy loading option in EF.

 

Regards,

Posted by Community Admin on 08-Dec-2015 00:00

Could you give me some feedback about this capability?

Posted by Community Admin on 11-Dec-2015 00:00

Hi Setxi,

In order to get a list of the fields of your content type dynamically you can try the following code:

// Set the provider name for the DynamicModuleManager here. All available providers are listed in
// Administration -> Settings -> Advanced -> DynamicModules -> Providers
var providerName = String.Empty;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type contenttypemtwoType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.ModuleName.ContenttypemName");  // set your content type
 
var moduleBuilderManager = ModuleBuilderManager.GetManager(providerName);
 
var dynamicModuleType = moduleBuilderManager.Provider.GetDynamicModuleTypes()
    .Where(t => t.TypeNamespace == contenttypemtwoType.Namespace).Single();
    //.Where(t => t.TypeName == type.Name && t.TypeNamespace == type.Namespace).Single();
 
var fields = moduleBuilderManager.Provider.GetDynamicModuleFields().Where(f => f.ParentTypeId == dynamicModuleType.Id && f.SpecialType == FieldSpecialType.None);


Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed