How to get image data from a dynamic module? - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How to get image data from a dynamic module?

  • How to get image data from a dynamic module?
  • Hi all,

    I am currently struggling with getting image data from my dynamic module. I have tried searching the net but still can't seem to get it working.

    I have an IQueryable type which holds a collection of dynamic items. I am trying to do the following:

                   IQueryable<DynamicContent> rawBusinessBlocks = (Query to Sitefinity);

                    return rawBusinessBlocks .Select(b => new BusinessBlockType()
                   
                        Title = b.GetValue<string>("Title"),
                        Body = b.GetValue<string>("Body"),
                        ExternalLink = b.GetValue<string>("ExternalLink"),
                        Image = b.GetRelatedItems<Image>("Image")
                    );

    When I try the above it returns an empty image collection. But when using a single item e.g. rawBusinessBlocks.FirstOrDefault().GetRelatedItems<Image>("Image") it does return an Image object. 

    Not sure why I can't query image data on an IQueryable collection instead of a single item, any ideas?

    Thank you all!

     

  • See: stackoverflow.com/.../how-to-retrieve-image-data-from-a-dynamic-module-collection-in-sitefinity-10