NestedContent property in a member node always null - umbraco8
Hi,
I've added NestedContent property for a certain member, And I tried to return the NestedConent values as I usually do for nodes, I used the below code:
member = Services.MemberService.GetByUsername(Membership.GetUser().UserName);
var NestedPackages = member.GetValue<IEnumerable<IPublishedElement>>("packages");
The member variable is of type IMember, which doesnt return iPublishedConent, it returns the raw value from the database which is in case of NestedContent a Json string. But you can convert this Json string to iPublishedContent by deserialize it via JsonConvert like this:
var NestedPackages = JsonConvert.DeserializeObject<IEnumerable<IPublishedElement>>(member.GetValue<string>("packages"));
I haven't tested the line above but i guess this could work.
NestedContent property in a member node always null - umbraco8
Hi,
I've added NestedContent property for a certain member, And I tried to return the NestedConent values as I usually do for nodes, I used the below code:
And I got the NestedPackages value as null.
Is there anyway to achieve it correctly ?
Thanks,
Hi Ahmed,
The member variable is of type IMember, which doesnt return iPublishedConent, it returns the raw value from the database which is in case of NestedContent a Json string. But you can convert this Json string to iPublishedContent by deserialize it via JsonConvert like this:
I haven't tested the line above but i guess this could work.
Best regards,
iNETZO
Hi iNETZO,
I have tried this way before, but i think we have better way like getting NestedContent in Razor.
Thanks for help,
Best regards,
Ahmed
is working on a reply...