2

Sharepoing2010の簡単な誕生日カレンダーのWebパーツを作成しています。

サイトのすべてのユーザーを繰り返し処理し、その日に誕生日を迎えたユーザーを表示する必要があります。ユーザーを名前のアルファベット順に表示する必要があります。

ilkeを実行すると、ユーザーリストを反復処理できます。

SPSite currentSite = ...
ServerContext ospServerContext = ServerContext.GetContext(currentSite);
UserProfileManager ospUserProfileManager = new UserProfileManager(ospServerContext);
foreach (UserProfile ospUserProfile in ospUserProfileManager) { ... }

ただし、プロファイルの順序を制御することはできません。いくつかの簡単なルールでプロファイルを並べ替える組み込みの方法はありますか、またはDictionary(string、UserProfile)を作成し、UserProfileManagerから入力し、キーで並べ替えてから、メンバーに対してforeachを実行する必要がありますか?

ありがとう!

4

1 に答える 1

3

ブロックを使用して追加:

using System.Linq;

ユーザープロファイルのコレクションを作成します。

var collection = new List<UserProfile>();

それを入力します:

foreach (UserProfile ospUserProfile in ospUserProfileManager) 
{ 
   collection.Add(ospUserProfile);
}

次にそれを並べ替えます

var sorted = collection.OrderBy(p => p.PropertyToSort);
于 2012-09-13T13:10:28.127 に答える