Code to Get and Set Multi-valued Profile Properties

Use the following code to get and set multi-valued profile properties. The code should be used within a Commerce Server project. For more information about creating a Commerce Server project, see Creating a Commerce Project.

Profile userProfile;
ProfilePropertyGroup generalInfo;
ProfileContext profileContext = CommerceContext.Current.ProfileSystem;
Array favColorsIn = Array.CreateInstance( typeof(String), 3);
// Create a user profile.
userProfile = profileContext.CreateProfile(LogonnameText.Text, "UserObject");

// Set multi-valued profile properties.
userProfile.PropertyGroups["GeneralInfo"]["fav_colors"].Value = favColorsIn;

// Persist user profile to underlying stores.
// Get multi-valued profile properties.
Array favColorsOut = (Array) userProfile.PropertyGroups["GeneralInfo"]["fav_colors"].Value;

Copyright © 2005 Microsoft Corporation.
All rights reserved.