More in this section
Forums / Developing with Sitefinity / How to get multiple ChooseOptions related to the Dynamic Module Type item

How to get multiple ChooseOptions related to the Dynamic Module Type item

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. Kolia
    Kolia avatar
    3 posts
    25 Jun 2012
    04 Feb 2016
    Link to this post

    I have the Dynamic Module Type DMType1 that includes field Field1 that has type of multiple chooses (Choose1,Choose2,Choose3).This selected chooses CMS store in the separate table (with dynamic name) where "base_id" column  is equals to the  DMType1 table item "base_id", column "seq" contain the choose number value, and "value" columns contain the string value for the choose .

    I have my own API that retrieve this DMType1 my using DynamicModuleManager to get them from CMS DB, and to get Field1 value, I need to use:

    var fild1Value = ((DynamicContent)dmType1 ).GetValue<ChoiceOption[]>("Field1")

    but it is very slow because I have lots DMType1 items, so I need to get all ChoiceOptions related to the DMType1 items  in one request to DB and then map options to the item by "base_id" (dmType1.Id).  


    What the correct way to do it?

  2. Georgi Dimitrov
    Georgi Dimitrov avatar
    9 posts
    02 Jun 2017
    09 Feb 2016
    Link to this post
    Hi Kolia,

    Thank you for contacting us.

    You can achieve desired behavior using DataAccess FetchStrategies, see the sample code bellow:
    var manager = DynamicModuleManager.GetManager();
    var type2Type = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Module1.Type1");
    var fetchStrategy = ((IOpenAccessDataProvider)manager.Provider).GetContext().FetchStrategy;
    if (fetchStrategy == null)
        fetchStrategy = new FetchStrategy();
    fetchStrategy.LoadWith("Telerik.Sitefinity.DynamicTypes.Model.Module1.Type1", "Choices");
    var items = manager.GetDataItems(type2Type).Where(i => i.Status == ContentLifecycleStatus.Live).ToList();

    Please do not hesitate to contact me again if you need any additional information.

    Georgi Dimitrov
    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. Kolia
    Kolia avatar
    3 posts
    25 Jun 2012
    10 Feb 2016 in reply to Georgi Dimitrov
    Link to this post

    Hi Georgi,

    Thank you for the reply this is exactly what I was looking for.

3 posts, 0 answered