FQL Execute Query

Feb 21, 2008 at 2:26 AM
Hi Nikhil,

I tried to use executequery using fql, it returns the ArrayList , now to for each object in array list i can use either the JSonObject or cast it to HashTable

I am getting problems doing both way,

a) when i use JSonObject to cast for each of array list, it gives me the access problems that i cannot use it
b) when using hashtable cast and then create a Facebook.Service.User object using
Hashtable t = (Hashtable)result;
Facebook.Service.User u = new Facebook.Service.User(t);

it says there is no 1 argument constructor in User class

I am new to this API, can u please suggest whic method is better to extract results from a call to fbservice.Fql.ExecuteQuery(query);
Thanks a lot
Feb 24, 2008 at 7:18 AM
Currently you have to use late-bound dictionary access with the hashtable.

The plan is to add an overload to Fql.ExecuteQuery to take in the type of object you want to create to hold the results sent back by Facebook... and then you'll have strongly typed entity objects to work against.
Feb 24, 2008 at 9:25 AM

Thanks for the repy, I am using that method to get the response

Why dont u allow us to use the JSonObject which is already there

Feb 24, 2008 at 4:00 PM
JsonObject is pretty much Hashtable + ICustomTypeDescriptor (which enables declarative data-binding scenarios). So if you want to imperatively get at name/value pairs, there is no difference between Hashtable and JsonObject - that is why JsonObject is not public.
May 13, 2008 at 8:49 AM
It was pretty hard to find out what to do with the result of an Fql.ExecuteQuery, but I managed to find out.
So I share it:


public static IEnumerable FqlQuery(string query, Facebook.Web.FacebookApplication fbApplication)




return fbApplication.Service.Fql.ExecuteQuery(query) as IEnumerable;



and an example of use:



IEnumerable friends = Repository.FqlQuery("SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=" + fb_uid + ")", fbApplication);



foreach (IDictionary friend in friends) { uid = friend["uid"]; }