2012-04-12 70 views
2

我想訂購由Facebook C#SDK按姓氏返回的Facebook朋友列表。使用LINQ是我能夠完成這一任務的最簡單方法,但我想知道是否有更簡單或更有效的方法?我想我至少會分享這個,因爲我找不到任何其他的例子。Facebook C#SDK朋友名單orderby name

var client = new FacebookClient(FBToken.Value); 
dynamic results = client.Get("me/friends?fields=id,name,picture"); 

var fbfsort = from dynamic friend in (IList<object>)results["data"] orderby friend.name ascending select friend; 
foreach (var f in fbfsort) { 
    //do something here... 
} 

回答

3

您可以使用FQL這樣的:

var client = new FacebookClient(FBToken.Value); 
dynamic result = client.Get("fql", new 
{ 
    q = "SELECT uid, name, pic_small from user where uid in (select uid2 from friend where uid1=me()) order by name" 
}); 

foreach (var item in result.data) 
{ 
    // do something here... 
} 

希望它能幫助!