In Commerce Server Profiles whenever we need a one-to-many relationships we use MultiValued properties. Something like One User can hold Multiple CreditCards then we use this. In this case we Create Following two Profile Types in Commerce Server,
1. CreditCard Profile : This profile will contain the informatiuon about a single credit card. This will have properties like Account Number, Type, Expiary date etc.
2. UserObject Profile : This profile will contain information about user like name, age, credit card list etc. The credit card list property need to contain multiple credit cards. For this we set the property type to CreditCard and set the Multi-Valued property to True.
Assigning CreditCards to userObject:
string[] creditcardlist= new string[n];
for(int i=0;i<n;i++)
{
Creditcardlist[i]=<credit_card_profile_id>;
}
userProfile.Properties["GeneralInfo.credit_card_list"].Value= creditcardlist
Retriving CreditCards from UserObject :
object[] objcreditcardlist = (object[])userProfile.Properties["GeneralInfo.credit_card_list"].Value;
foreach(string creditcardid in objcreditcardlist)
Fetch the creditcard profile using creditcard id..
Deleting all CreditCards from UserObject :
userProfile.Properties["GeneralInfo.credit_card_list"].Value = DBNull.Value;