Интерес пользователя 1 («Баскетбол», «Хоккей», «Бейсбол»)
Интересы пользователя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
}
}