How to assign a MediaReferenceList<MediaReference> in code

Vote:
 

Hi

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

[BackingType(typeof(PropertyMediaList))]
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.

Thanks

/ Johan

#116465
Jan 30, 2015 11:44
Vote:
 

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;
}
#116575
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.