How to assign a MediaReferenceList<MediaReference> in code



I am creating pages programmatically that has Image Vault MediaReferenceList property like this:

public virtual MediaReferenceList Images { get; set; }

Creating product:

var product = (Product)contentRep.GetDefault(ContentReference.StartPage).CreateWritableClone();

product.Images = new MediaReferenceList();

product.Images is always null no matter what.


/ Johan

Jan 30, 2015 11:44

I think the list needs to contain at least one item.

var mediaLinks = new MediaReferenceList<MediaReference>();
mediaLinks.Add(new MediaReference { Id = 1 });

if (mediaLinks.Any())
	product.Images = mediaLinks;
Edited, Feb 02, 2015 14: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.