Mike, I believe that what you watched is true. I am working with a ProfileProvider that uses Azure TableStorage as a data store. I wanted to get a list of user profiles from a database and combine them with information from a membership provider. It took some time until I realized that calling ProfileBase.Create () with the username as an argument searches in TableStorage and actually retrieves the data associated with that username. As far as I know, calling this Create () method is misleading, I would expect Load () or Get (). Currently my code is as follows:
public IEnumerable<AggregatedUser> GetAllAggregatedUsers() { ProfileInfoCollection allProfiles = this.GetAllUsersCore( ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All) ); //AggregatedUser is simply a custom Class that holds all the properties (Email, FirstName) that are being used var allUsers = new List<AggregatedUser>(); AggregatedUser currentUser = null; MembershipUser currentMember = null; foreach (ProfileInfo profile in allProfiles) { currentUser = null; // Fetch profile information from profile store ProfileBase webProfile = ProfileBase.Create(profile.UserName); // Fetch core information from membership store currentMember = Membership.FindUsersByName(profile.UserName)[profile.UserName]; if (currentMember == null) continue; currentUser = new AggregatedUser(); currentUser.Email = currentMember.Email; currentUser.FirstName = GetStringValue(webProfile, "FirstName"); currentUser.LastName = GetStringValue(webProfile, "LastName"); currentUser.Roles = Roles.GetRolesForUser(profile.UserName); currentUser.Username = profile.UserName; allUsers.Add(currentUser); } return allUsers; } private String GetStringValue(ProfileBase profile, String valueName) { if (profile == null) return String.Empty; var propValue = profile.PropertyValues[valueName]; if (propValue == null) return String.Empty; return propValue.PropertyValue as String; }
Is there a better (simpler, more efficient) way
- Get all custom profile information from the profile provider and
- combine them with membership provider information to show them, for example. on the admin page?
I looked at Web Profile Builder , but IMO it only provides intellisense development for user profile properties by creating a proxy class.
Masterfu
source share