4

マルチクエリを使用して友達のチェックインを取得しています。期待どおりにデータを返すクエリがありますが、やりたいことは、各クエリの要素を含む DataTable を作成することです。結果は 3 つしかありませんが、データには少なくとも 100 件あります。ループが間違っていることを知っている以外に、何が間違っているのかわかりません。皮肉なことに、3 はクエリの数です。私;それは私のforeachだと確信していますが、何をループすべきかわかりません。助けてください。

dynamic resultCheckins = fb.Get("fql",
   new
   {
       q = new
       {
           friends_checkins = "SELECT author_uid, coords, timestamp, page_id, message FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())",
           users = "SELECT uid, name, pic_small from user where uid IN (SELECT author_uid FROM #friends_checkins)",
           resultCheckins = "SELECT page_id, name, description from place where page_id IN (SELECT page_id FROM #friends_checkins)",
       }
   });

JObject resultCheckinsJson = JObject.Parse(resultCheckins.ToString());
DataTable CheckIn = new DataTable();
CheckIn.Columns.Add(new DataColumn("Friend", typeof(string)));
CheckIn.Columns.Add(new DataColumn("Picture", typeof(string)));
CheckIn.Columns.Add(new DataColumn("Link", typeof(string)));
CheckIn.Columns.Add(new DataColumn("Place", typeof(string)));
CheckIn.Columns.Add(new DataColumn("Coords", typeof(string)));
CheckIn.Columns.Add(new DataColumn("When", typeof(string)));
CheckIn.Columns.Add(new DataColumn("Message", typeof(string)));

int thiscounter = 0;
foreach (var row in resultCheckinsJson["data"].Children())
{
    string placename = resultCheckins.data[1].fql_result_set[thiscounter].name.ToString().Replace("\"", "");
    string NavigateURL = "http://facebook.com/" + resultCheckins.data[1].fql_result_set[thiscounter].page_id.ToString().Replace("\"", "");

    DataRow CheckInRow = CheckIn.NewRow();
    CheckInRow["Friend"] = resultCheckins.data[2].fql_result_set[thiscounter].name;
    CheckInRow["Picture"] = resultCheckins.data[2].fql_result_set[thiscounter].pic_small;
    CheckInRow["Link"] = ResolveUrl(NavigateURL);
    CheckInRow["Place"] = resultCheckins.data[1].fql_result_set[thiscounter].name.ToString().Replace("\"", "");
    CheckInRow["Coords"] = resultCheckins.data[0].fql_result_set[thiscounter].coords.ToString().Replace("\"", "");
    DateTime dtDateTime =  dtDateTime.AddSeconds(resultCheckins.data[0].fql_result_set[thiscounter].timestamp).ToLocalTime();
    CheckInRow["When"] = dtDateTime.ToString();
    CheckInRow["Message"] = resultCheckins.data[0].fql_result_set[thiscounter].message.ToString();
    CheckIn.Rows.Add(CheckInRow);
    thiscounter++;
}
4

1 に答える 1

0

この行を変更してみてください:

foreach (var row in resultCheckinsJson["data"].Children())

に:

foreach (resultCheckinsJson.data の動的行)

次に、次のようなプロパティを取得します。

row.name
于 2013-08-14T15:58:03.460 に答える