create generic property for member type that can act as foreign key to custom tables
Hello,
I'm new to umbraco and am stuck on a specific issue. I'm currently working on a member registration screen. This works nicely/easily with all the standard .net membership stuff. I am working with the umbracoMemberProfileProvider to already have some custom profile properties (like the isApproved, isLocked, name, phone, country,...). This works nice as I can just create generic properties on the membertype.
One of the properties my members must have is a company. And this company will have to be used as a foreign key to the rest of my custom tables (that are in the same database as the umbraco tables). This company name will decide what a user is allowed to see!
So I can't just create a new generic property in the membertype because that will just create some records in the cmspropertydata and type table and I don't see how I could put the link (to my custom tables) up there.
One way I was thinking is to create a companyInfo table and then also a CompanyMember table. This CompanyMember table will then just hold a memberid (link to the nodeid in the cmsMember table) and a companyID (link to the custom companyInfo table). I'm just not sure how to nicely retrieve the data as I'm also working with the MemberProfile to easily get the custom properties. I could of course in my MemberProfile (which inherits from ProfileBase) add a method/property that would be in charge of gettting/setting the company info based on the memberid I would pass in. But this doesn't really seem nice.
So does anybody have another solution for this?
I hope the problem is clear enough?
Edit: Or would another (easier) option be just creating a new generic property of type numeric which would hold the id to the custom company info table? The only thing missing here would of course be the foreign key not existing on databae level.
I have thought about this but it is not a real option for us. This would mean that when somebody is registering they would see all the companies that we already have registered in our site. And this is something we do not want.
The route I'm thinking of now (as posted as edit in my original question):
Have a generic numeric property which will contain the id of the company. In the profile property of this company I would then create a new company record and assign the id (primary key) to the generic property. This way the member knows to which company he/she belongs. The only downside of this is that there is no foreign key relationship defined and also it requires some extra work to manualy do the mapping between the id and getting the actual company info.
Hi Kevin,
I see what you mean, but when I meant drop down list this would be a property in Umbraco, which doesn't need to be visible on the website. Essentially it's an ID to the user but to any editors who have visibility of Members in the back office they could see the relationship in a meaningful way.
create generic property for member type that can act as foreign key to custom tables
Hello,
I'm new to umbraco and am stuck on a specific issue. I'm currently working on a member registration screen. This works nicely/easily with all the standard .net membership stuff. I am working with the umbracoMemberProfileProvider to already have some custom profile properties (like the isApproved, isLocked, name, phone, country,...). This works nice as I can just create generic properties on the membertype.
One of the properties my members must have is a company. And this company will have to be used as a foreign key to the rest of my custom tables (that are in the same database as the umbraco tables). This company name will decide what a user is allowed to see!
So I can't just create a new generic property in the membertype because that will just create some records in the cmspropertydata and type table and I don't see how I could put the link (to my custom tables) up there.
One way I was thinking is to create a companyInfo table and then also a CompanyMember table. This CompanyMember table will then just hold a memberid (link to the nodeid in the cmsMember table) and a companyID (link to the custom companyInfo table). I'm just not sure how to nicely retrieve the data as I'm also working with the MemberProfile to easily get the custom properties. I could of course in my MemberProfile (which inherits from ProfileBase) add a method/property that would be in charge of gettting/setting the company info based on the memberid I would pass in. But this doesn't really seem nice.
So does anybody have another solution for this?
I hope the problem is clear enough?
Edit: Or would another (easier) option be just creating a new generic property of type numeric which would hold the id to the custom company info table? The only thing missing here would of course be the foreign key not existing on databae level.
Hi Kevin,
Could you not make a custom data type like a drop down list which is populated by the table which has the foreign keys?
That way you always have the data up to date and it becomes a property of the member.
Jamie
Hi Jamie,
I have thought about this but it is not a real option for us. This would mean that when somebody is registering they would see all the companies that we already have registered in our site. And this is something we do not want.
The route I'm thinking of now (as posted as edit in my original question): Have a generic numeric property which will contain the id of the company. In the profile property of this company I would then create a new company record and assign the id (primary key) to the generic property. This way the member knows to which company he/she belongs. The only downside of this is that there is no foreign key relationship defined and also it requires some extra work to manualy do the mapping between the id and getting the actual company info.
Don't know what you think of that!?
Hi Kevin,
I see what you mean, but when I meant drop down list this would be a property in Umbraco, which doesn't need to be visible on the website. Essentially it's an ID to the user but to any editors who have visibility of Members in the back office they could see the relationship in a meaningful way.
Jamie
is working on a reply...