+1-888-365-2779
Try Now
More in this section

Forums / Module Builder / Getting related data and childs dinamically in code

Getting related data and childs dinamically in code

3 posts, 0 answered
  1. Setxi
    Setxi avatar
    7 posts
    Registered:
    16 Mar 2015
    30 Nov 2015
    Link to this post

    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. 

     

    http://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,

  2. Setxi
    Setxi avatar
    7 posts
    Registered:
    16 Mar 2015
    08 Dec 2015
    Link to this post
    Could you give me some feedback about this capability?
  3. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    27 Sep 2016
    11 Dec 2015
    Link to this post
    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
     
3 posts, 0 answered