Rastak
Rastak

Reputation: 46

Umbraco IMember AdditionalData

I want to store some information for a member in Umbraco using the AdditionalData dictionary field.

First I get the member (this code is located in a SurfaceController):

var member = Services.MemberService.GetByUsername("username");

Then I add the data

member.AdditionalData.Add("SomeDataKey", "SomeData");

And save it.

Services.MemberService.Save(member);

When I fetch the same member again after it has been saved, the member does not contain the AdditionalData anymore.

I don't want to create an extra property to save this data. I want to use it as described in the documentation. (IUmbracoEntity: AdditionalData property)

Some entities may expose additional data that other's might not, this custom data will be available in this collection

Q: Am I missing something or could someone point me in the right direction?

Q: Is the AdditionalData stored somewhere or is this temporary

(Umbraco 7.2.4)

Best regards,

Tom

(Umbraco forum: link)

Upvotes: 0

Views: 495

Answers (1)

Rob Purcell
Rob Purcell

Reputation: 1285

To retrieve custom property values for the member you can use:

var member = Services.MemberService.GetByUsername("username");

var myPropertyValue = member.GetValue<string>("myPropertyAlias");

Upvotes: 1

Related Questions