-1

我在从 facebook(朋友列表)检索信息的应用程序上工作,当我从 facebook 检索列表时,想要将它们转换为我的模型并将它们存储在数据库中之后,可以将 Facebook.JsonObject 转换为我的模型吗?:

             dynamic myInfo = _fb.Get("/me/friends?fields=id,name,picture");

            dynamic fbfsort = from dynamic friend in (IList<object>) myInfo["data"] 
                              orderby friend.name ascending 
                              select friend;

             foreach (UserFriend friend in fbfsort) {
                    entity.Friends.Add(friend);

                    }
4

1 回答 1

0
dynamic myInfo = _fb.Get("/me/friends?fields=id,name,picture");

entity.Friends = (
     from dynamic friend 
       in (IList<object>) myInfo["data"] 
  orderby friend.name ascending  
   select new UserFriend()  {
               Id = (long)friend.id, 
               Name = (string)friend.name,
               Picture = (string)friend.picture }
).ToList();
于 2012-05-14T22:37:16.673 回答