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

Forums / Developing with Sitefinity / Why does DynamicModuleManager.GetDataItems(type) return duplicate items?

Why does DynamicModuleManager.GetDataItems(type) return duplicate items?

4 posts, 0 answered
  1. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    06 Mar 2012
    Link to this post
    QUESTION:
    In Sitefinity 4.4, I created a new custom module with module builder. I entered 4 items, but when I retrieve them with GetDataItems, I get 8 back. Why am I getting a duplicate of each?

    DETAILS:
    Each item looks like this:

    Top Menu Items
    -------------------
    menuItem (string)
    menuBody (long text)
    sortOrder (numeric)

    I entered 4 items. Only 4. They are simple. I run the following code to retrieve those 4 items in order (based on the sort order), and I get 8 back. Why?

    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
     
    Type topMenuItemType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.TopMenus.TopMenuItem");
                 
    var MenuItems = dynamicModuleManager.GetDataItems(topMenuItemType).OrderBy("menuOrder").AsEnumerable();
  2. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    06 Mar 2012
    Link to this post
    Looking into the DynamicContent that was returned, the duplicate items are mostly the same except:

    ID is different (off by a minute)
    Status is different (one is "Live", and one is "Master")
    Visibility is different. (one true, one false)

    So I still don't know WHY there is a duplicate, but I will try to filter one out, maybe based on visibility.

  3. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    06 Mar 2012
    Link to this post
    If I add the following, it works as intended. (I get 4 results rather than duplicated 8)

    .Where("Visible == true")

  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    07 Mar 2012
    Link to this post
    Hey Dan,
      Live and Master are global content concepts, but yeah this article doesn't really go into detail on the EXACT difference....however one level up there's a detailed description on which is which here

    Steve
4 posts, 0 answered