Images are only filled after filtering
Hey there,
I am developing a website with custom content types. I created the content types with the module builder (latest Sitefinity).
All custom content types contain images. I can see the images in the backend, after creating the items. When I am querying the items with
var dynamicModuleManager = DynamicModuleManager.GetManager(PROVIDER_NAME);
var editionType = TypeResolutionService.ResolveType(TYPE_NAME);
IQueryable<DynamicContent> allEditions = dynamicModuleManager.GetDataItems(editionType);
And getting the images with:
allEditions.First().DynamicContent.GetValue("Images");
the return value is an empty list. I also tried to cast them to ContentLink[] as mentioned here and here but this throws an exception. What works is a cast to ICollection<IDataItem>
In one of the content types there is an field of type Address. After filtering these items with:
((IGeoLocationManager)dynamicModuleManager).FilterByGeoLocation
the Images field is not empty anymore.
In other content types I do not have this option. Can someone help me?
Best regards,
David
Try this
dataItem.GetRelatedItems<Image>("Images");
...no more stupid dealing with ContentLinks...you get a list of pure image objects
I tried it, but the enumeration is empty. Just like I said.
Hey there,
when I am getting a single item with
dynamicModuleManager.GetDataItem(editionType, id);
the Images are present. Then I can use
dataItem.GetRelatedItems<Image>("Images");
as suggested by Steve.