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

 

We have the following code snippet:

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

var assets = new List<TContentMedia>();

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

var assetQuery = assetContainer.CommerceMediaCollection.Select(media => media).Where(x => ValidateCorrectType<TContentMedia>(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