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

Forums / Bugs & Issues / DynamicModuleManager returning duplicates

DynamicModuleManager returning duplicates

2 posts, 0 answered
  1. Dan
    Dan avatar
    14 posts
    Registered:
    01 Dec 2014
    09 Mar 2015
    Link to this post

    Hi,

    We recently upgrade to Sitefinity 7.2 and now custom content types we had created when we were using Sitefinity 6.3 are returning duplicates.  We inspected the database and noticed that every item has 2 rows associated with it, and the GUID's differ only slightly.  e.g. 2AE63F0D-3E54-6B96-8484-FF0000E1ED88 and 34E63F0D-3E54-6B96-8484-FF0000E1ED88.  The 2 rows contain the exact same data.  We are not sure if this is by design or not.  Regardless, most of the code we have in place is now showing duplicates.

    Any idea why this might be?

     Example code getting all the items of a particular content type:

    DynamicModuleManager dmm = DynamicModuleManager.GetManager();
                Type locationType = TypeResolutionService.ResolveType(HealthwaysConstants.CONTENT_TYPE_LOCATION);
                var locs = dmm.GetDataItems(locationType).Select(dc => new Location
                {
                    Name = dc.GetValue<string>(NAME),
                    Address = dc.GetValue<string>(ADDRESS),
                    City = dc.GetValue<string>(CITY),
                    State = dc.GetValue<string>(STATE),
                    Zip = dc.GetValue<string>(ZIP),
                    Latitude = dc.GetValue<decimal?>(LATITUDE),
                    Longitude = dc.GetValue<decimal?>(LONGITUDE)
                }).ToList();
                rptResults.DataSource = locs;
                rptResults.DataBind();

    Thanks,

     Dan

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    09 Mar 2015 in reply to Dan
    Link to this post

    Hi Dan,

    Yes, this is by design. Every item is stored as a Master and there is also a Live version.
    If you adjust your code like this, you will get only the Live versions:

    DynamicModuleManager dmm = DynamicModuleManager.GetManager();
                Type locationType = TypeResolutionService.ResolveType(HealthwaysConstants.CONTENT_TYPE_LOCATION);
                var locs = dmm.GetDataItems(locationType).Where(x => x.Status == ContentLifecycleStatus.Live).Select(dc => new Location
                {
                    Name = dc.GetValue<string>(NAME),
                    Address = dc.GetValue<string>(ADDRESS),
                    City = dc.GetValue<string>(CITY),
                    State = dc.GetValue<string>(STATE),
                    Zip = dc.GetValue<string>(ZIP),
                    Latitude = dc.GetValue<decimal?>(LATITUDE),
                    Longitude = dc.GetValue<decimal?>(LONGITUDE)
                }).ToList();
                rptResults.DataSource = locs;
                rptResults.DataBind();

    You can find more information here: http://docs.sitefinity.com/for-developers-query-master-and-live-versions

    Best,
    Daniel 

     

     

     

2 posts, 0 answered