I have used the KEYWORD dynamic and it is only available in .net 4.0 but I have to roll-back to a .net 3.5 server. I can not use KEYWORD dynamic anymore and need to convert it to work with .net 3.5. I have a class, FBWeird,that I thought I could cast against but it doesn't work when I put it in fb.Query(query). I use this same method when I rolled back a .Get statement and .Get(id) works for me but not in this instance. Can anyone help me with the below code to get it back working?
CODE
var fb = new FacebookWebClient(accessToken.ToString());
var fbResults = fb.Query("SELECT like_count,normalized_url FROM link_stat WHERE url='http://www.facebook.com/cocacola");
long likeCount = fbResults.like_count;
Response.Write(fbResults.ToString());
CLASS
public class FBWeird
{
public string like_count { get; set; }
}
EDIT
Ok, so some down-voting doubters, for some reason, went all weird on my question. So.. for the doubters, this is what how you do it:
List<FBWeird> entities = (List<FBWeird>)Newtonsoft.Json.JsonConvert.DeserializeObject(fbResults.ToString(), typeof(List<FBWeird>));
foreach (FBWeird obj in entities)
开发者_开发知识库 {
thisLikeCount = obj.like_count;
}
Output that however you want and it works awesome.
It appears that you're using the Facebook C# SDK. The SDK has two solutions in it - one for 4.0 and one for 3.5. Load the 3.5 solution and compile it and use that DLL instead. Is that what you did to fix it?
精彩评论