0

我正在将一些遗留代码从 C# Facebook SDK 的旧 3.0 版本更新到新的 5.3.2 版本。

http://developers.facebook.com/docs/reference/fql/ 上,它表明您可以执行多重查询,例如:

"query1":"SELECT uid, rsvp_status FROM event_member WHERE eid=12345678"
"query2":"SELECT name, url, pic FROM profile WHERE id IN (SELECT uid FROM #query1)"

在旧 API 中,您只有一个字典,其中每个查询都与其名称配对:

"page_admin_list","SELECT uid, page_id, type FROM page_admin where uid = 1234567890"
"permissions_response","SELECT uid, read_stream, status_update, photo_upload, publish_stream, offline_access FROM permissions WHERE uid IN (SELECT page_id FROM #page_admin_list)"

在每个示例中,请注意嵌套查询中的 #。但是,我不确定如何使用新语法来完成此操作,因为它只接受 string[] 作为参数。

4

2 回答 2

0

找到了这个答案(编辑这适用于早期版本的 sdk,对于版本 6 及更高版本,请参阅 prabir 的答案):我必须通过 #query0、#query1 等引用每个查询...

或者我可以使用 Get() 方法而不是 Query() 方法

var queries = 
    new Dictionary<string, object>
    {
        { "FamDamly", "select uid from family where profile_id = me()" },
        { "FamDetails", "select uid, first_name from user where uid in #FamDamly" }
    };
client.Get(queries);
于 2011-11-22T22:18:47.447 回答
0

从 Facebook C# SDK v6 开始,您可以使用以下方法执行命名查询。

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("fql",
    new
        {
            q = new
            {
                id = "SELECT uid from user where uid=me()",
                name = "SELECT name FROM user WHERE uid IN (SELECT uid FROM #id)",
            }
        });
于 2012-02-20T14:48:56.750 回答