Getting related data and childs dinamically in code - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Getting related data and childs dinamically in code

  • Getting related data and childs dinamically in code
  • 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. 


    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.



  • Could you give me some feedback about this capability?
  • 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);

    Svetoslav Manchev
    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