将Facebook.JsonObject转换为我的模型

时间:2012-05-14 15:32:29

标签: json facebook-c#-sdk

我在从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);

                    }

1 个答案:

答案 0 :(得分: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();