1
User1的利息( '籃球', '曲棍球', '棒球')更快的方法來比較2 UserProfileValueCollection
用戶2的利息( '拳擊', '籃球')
using(SPSite site = new SPSite(SPContext.Current.Web.Url)){
using(SPWeb web = site.OpenWeb()){
ServerContext oContext = ServerContext.GetContext(site);
UserProfileManager upManager = new UserProfileManager(oContext);
UserProfile User1Profile = upManager.GetUserProfile(user1.LoginName); // user1 is SPUser
UserProfile User2Profile = upManager.GetUserProfile(user2.LoginName); // user2 is SPUser
/// Faster way to check if the interest of User1 have something common in User2
/// In the interest list above user1 and user2 have a common interest on Basketball
/// How will I do this checking. I prefer a faster approach like the Array.IndexOf
/// but this can't be done on the UserProfileValueCollection.
}
}
我希望我可以使用更快的比較方式,因爲我很有可能會比較超過200個不同興趣的用戶。所以,我最終會做這個
///Search common interest among the members of the group
foreach(SPUser user in oweb.Groups[0].Users){
if(CurrentlyLoggedInUser have common interest with user){
///do the necessary logic here
}
}