Try our conversational search powered by Generative AI!

How to set "DownloadItemType" readonly property of Asset "TContentMedia" type object.

Vote:
 

We have the following code snippet:

public static IList GetAssets(this IAssetContainer assetContainer, IContentLoader contentLoader, IUrlResolver urlResolver)
where TContentMedia : IContentMedia
{

var assets = new List();

if (assetContainer?.CommerceMediaCollection == null)
{
return assets;
}

var assetQuery = assetContainer.CommerceMediaCollection.Select(media => media).Where(x => ValidateCorrectType(x.AssetLink, contentLoader));

foreach (var media in assetQuery)
{
if (contentLoader.TryGet(media.AssetLink, out TContentMedia asset))
{
if (!asset.IsDeleted)
{

 var mediaGroupName = media.GroupName;

asset.Property["DownloadItemType"].Value = mediaGroupName ;

}

assets.Add(asset);
}
}
}

return assets;
}

code in code causing problem not able to set the read only property; please suggest the  how to set the "DownloadItemType" property value.

#190736
Apr 16, 2018 16:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.