New Rotator query

Posted by Community Admin on 04-Aug-2018 00:21

New Rotator query

All Replies

Posted by Community Admin on 21-Mar-2012 00:00

Hi,

I have created a Dynamic Module that I am using to display ads. I have adapted your NewsRotator example to fit my scenerio. Everything seems to work fine until I run the query to join my dynamic content and the image.

Below is the query used for the NewsRotator example:

var dataSource = App.WorkWith().NewsItems().Publihed()
                                                .Get().Take(this.NewsLimit)
                                                .ToList()
                                                .Join(
                                                    App.WorkWith().Images().Publihed()
                                                    .Get()
                                                    .Where(i => i.Parent.Title == "Thumbnails"),
                                                        item => item.Title.Value,
                                                        image => image.Title.Value,
                                                        (item, image) => new NewsItem = item, NewsImage = image
                                                );

And here is my code,
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type businessPremiumListingType = TypeResolutionService.ResolveType(PremiumListingContentType);
             
            var imagesQuery = App.WorkWith().Images().Publihed()
                                                            .Get()
                                                            .Where(i => i.Parent.Title == "Thumbnails");
 
            var datasource = dynamicModuleManager.GetDataItems(businessPremiumListingType)
                                                    .Where(i => i.Status == ContentLifecycleStatus.Live && i.Visible == true)
                                                    .Take(this.BusinessLimit);
 
            var ds = datasource.Join(imagesQuery,
                                      item => item.GetValue<Guid>("ad"),
                                      image => image.Id,
                                      (item, image) => new BusinessItem = item, BusinessImage = image );

My Dynamic module has a field called ad the holds the id of the image that I want to display. This query looks fine to me but when it executes, I get the following error:

Incorrect number of parameters supplied for lambda declaration

I do not see what the difference is between my code and the NewsRotator example. Can anyone shed some light on why this is happening and the correct implementation for what I am trying to accomplish?

Thanks,
Bobby

This thread is closed