This project is read-only.

FqlService.ExecuteQuery return value

Oct 30, 2007 at 5:06 AM
Edited Oct 30, 2007 at 5:07 AM

I'm just wondering if anyone know; to which object can I cast the result of an fql query to get access to its members?

For e.g:

/* my connection code */
FacebookConnection connection = FacebookConnection.CreateInstance();
FqlService service = connection.CurrentApplication.Service.Fql;

/* the fql query */
Object result = service.ExecuteQuery(String.Format("SELECT name, pic FROM user WHERE uid={0}", userid));

How do I access the name and pic collection from the result?
All I want to do is to be able to iterate the result collection and hydrate my domain objects using the information

/* hydrate */
for ( someBaseFacebookNetClass facebookNetobject in result )
User usr = new User();
usr.Name = facebookNetObject["name"]
usr.Pic = facebookNetObject["pic"]
Nov 1, 2007 at 10:42 AM
Nothing that a quick peek into the source code can't solve :-)

Here is the answer for those of you who has the same problem:

result is really a collection of Facebook.Service.Core.JsonObject, which is really a hashtable. So following the above examples:

internal User(string name, string pic)

resultList = (IList) result;

for (Hashtable object in resultList)
User usr = new User(object"name", object"pic");

There you go.