Umbraco 8 how to parse IMember to strongly typed MemberType
Hi All,
I am wondering how to convery an IMember to a MemberType.
So I have access to the strongly typed fields.
So I have a member which has a load of custom fields.
I use the following code to get the member.
IMember member = _memberService.GetByEmail(email);
I am just not sure how to get access to the custom fields.
Notice how I am using the membership helper to get the member instead of the service. This will bring back IPublishedContent which you can then cast as your member type and have access to all the custom profile fields as strongly typed properties.
Umbraco 8 how to parse IMember to strongly typed MemberType
Hi All,
I am wondering how to convery an IMember to a MemberType. So I have access to the strongly typed fields. So I have a member which has a load of custom fields. I use the following code to get the member. IMember member = _memberService.GetByEmail(email); I am just not sure how to get access to the custom fields.
Thanks.
Hi Nathan,
If you think of a memeber as a content node that will set you on the right path.
Like with content there is helpers and services. Helpers generally get the data from cache and services get from the DB.
It looks as though you are using the service when in-fact you are probably wanting to use a helper method instead.
Try this code
Notice how I am using the membership helper to get the member instead of the service. This will bring back IPublishedContent which you can then cast as your member type and have access to all the custom profile fields as strongly typed properties.
I am sure this will help you.
Regards
David
Hi David,
A small suggestion for your method:
You could add the logging, but I don't see that it should fail :)
is working on a reply...