Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I try to use a custom Media property. But I get:
Object not set to an instance of an object.
The x.GetPropertyValue doesn't find the custom Media properties at all. Does anyone know how to go about this?
I use ver 6.1.5
var rootMedia = Umbraco.TypedMediaAtRoot(); var rootFiles = rootMedia.Select(x => x) .Where(x => x.DocumentTypeAlias == "File" && x.GetPropertyValue("umbracoExtension").ToString().Contains("pdf")); var descendantFiles = rootMedia.SelectMany(x => x.Descendants()) .Where(x => x.DocumentTypeAlias == "File" && x.GetPropertyValue("umbracoExtension").ToString().Contains("pdf")); var oFiles = rootFiles.Union(descendantFiles) .Where(x => x.GetPropertyValue("documentMetaData").ToString().Contains(metadata_id)) .OrderByDescending(x => x.CreateDate);
Hi Jerker,
I had no problem getting the below sample to work with Umbraco v6.1.6, (I only made a few small tweaks, but your original sample worked also). What do you have in the variable metadata_id?
@{ var rootMedia = Umbraco.TypedMediaAtRoot(); var rootFiles = rootMedia.Select(x => x) .Where(x => x.DocumentTypeAlias == "File" && x.GetPropertyValue<string>("umbracoExtension").Contains("pdf")); var descendantFiles = rootMedia.SelectMany(x => x.Descendants()) .Where(x => x.DocumentTypeAlias == "File" && x.GetPropertyValue<string>("umbracoExtension").Contains("pdf")); var oFiles = rootFiles.Union(descendantFiles) .Where(x => x.GetPropertyValue<string>("documentMetaData").Contains("something")) .OrderByDescending(x => x.CreateDate); } <p>@oFiles.Count()</p>
Jeavon
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Custom Media property problem
I try to use a custom Media property. But I get:
Object not set to an instance of an object.
The x.GetPropertyValue doesn't find the custom Media properties at all. Does anyone know how to go about this?
I use ver 6.1.5
Hi Jerker,
I had no problem getting the below sample to work with Umbraco v6.1.6, (I only made a few small tweaks, but your original sample worked also). What do you have in the variable metadata_id?
Jeavon
is working on a reply...