How to configure Umbraco Profile Provider for multiple Member Types
Hi Guys,
I'm working on a project where we have 2 member types "Member" and "Artist". To keep my project as flexible as possible, I'd like to follow Aaron Powels method of mapping the properties to a class, and then use the built in Profile features of asp.net (http://www.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx) My question is, how can I do this, with 2 member types? as the profile element in the web.config only allows you to inherit one class. Are you able to add multiple profile elements to the web.config? (I couldn't find any info on this on google).
In my app, "Artist" is technicaly just an extension of "Member", so could I get the profile to inherit the "Artist" profile class, which itself inherits the "Member" profile class and then just cast the result whether they are in either of the roles? Would umbraco know which member type property to save the value to?
I'm not entirely sure that ASP.NET supports this to begin with, so you could be out of luck without doing something freaky.
I'd try having the two classes, with the Artist inheriting Member, and Artist being the 'default'. Because of the inheritance you can always down-cast it when you just need a Member class. You'd need to check how the properties which don't map to Member are dealt with, you'll have to use the debugger for that, but there will likely be an exception you can handle.
I've been thinking today of possibly writing a custom profile provider. I was thinking that I could use the group tag, and for the name, use the alias of the memberType. Then in the profile provider, it can check the what memberType the user is and just save those properties. Then possibley use and explicit operator to cast the generic profilebase to a typed class. What do you think?
How to configure Umbraco Profile Provider for multiple Member Types
Hi Guys,
I'm working on a project where we have 2 member types "Member" and "Artist". To keep my project as flexible as possible, I'd like to follow Aaron Powels method of mapping the properties to a class, and then use the built in Profile features of asp.net (http://www.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx) My question is, how can I do this, with 2 member types? as the profile element in the web.config only allows you to inherit one class. Are you able to add multiple profile elements to the web.config? (I couldn't find any info on this on google).
In my app, "Artist" is technicaly just an extension of "Member", so could I get the profile to inherit the "Artist" profile class, which itself inherits the "Member" profile class and then just cast the result whether they are in either of the roles? Would umbraco know which member type property to save the value to?
I hope this makes sence.
Many thanks
Matt
How do others work with multiple member types? Do you just use the Umbraco API?
I'm not entirely sure that ASP.NET supports this to begin with, so you could be out of luck without doing something freaky.
I'd try having the two classes, with the Artist inheriting Member, and Artist being the 'default'. Because of the inheritance you can always down-cast it when you just need a Member class.
You'd need to check how the properties which don't map to Member are dealt with, you'll have to use the debugger for that, but there will likely be an exception you can handle.
Yea, the nearest I've found within ASP.NET is the use of the group tag to group properties together.
I will try the inheritance route and see how it goes, but would still love to know how others are handling multiple member types and their data.
Matt
I've been thinking today of possibly writing a custom profile provider. I was thinking that I could use the group tag, and for the name, use the alias of the memberType. Then in the profile provider, it can check the what memberType the user is and just save those properties. Then possibley use and explicit operator to cast the generic profilebase to a typed class. What do you think?
You can use the explicit operator to do a cast between any two types, that's the point of it (as long as you've got the source for the target type).
Matt
How did you end up going about configuring Umbraco Profile Provider for multiple member types?
I'd like to know the same thing!
is working on a reply...