1

I found example in parse.com. I have 2 objects : Post and Comment, in the Comment objects have a collumn: "parent" pointer to Post obj and I want to join them:

var query = ParseObject.GetQuery ("Comment");
// Include the post data with each comment
query = query.Include("parent");
query.FindAsync().ContinueWith(t => {
    IEnumerable<ParseObject> comments = t.Result;
        // Comments now contains the last ten comments, and the "post" field
        // contains an object that has already been fetched.  For example:
    foreach (var comment in comments)
    {

        // This does not require a network access.
        string o= comment.Get<string>("content");
        Debug.Log(o);
        try {
            string post = comment.Get<ParseObject>("parent").Get<string>("title");
            Debug.Log(post);


        } catch (Exception ex) {
            Debug.Log(ex);  
        }
    }

});

It worked! And then, I have 2 objects: User and Gamescore, in the Gamescore objects have a collumn: "playerName" pointer to Post obj I want join them too:

var query = ParseObject.GetQuery ("GameScore");
        query.Include ("playerName");
        query.FindAsync ().ContinueWith (t =>{
            IEnumerable<ParseObject> result = t.Result;
            foreach (var item in result) {
                Debug.Log("List score: ");
                int score = item.Get<int>("score");
                Debug.Log(score);
                try {
                    var obj = item.Get<ParseUser>("playerName");
                    string name = obj.Get<string>("profile");
                    //string name = item.Get<ParseUser>("playerName").Get<string>("profile");

                    Debug.Log(name);

                } catch (Exception ex) {
                    Debug.Log(ex);  
                }
            }
        });

but It isn't working, Please help me!

1
  • Help Me. Please. Anybody.? Commented Apr 26, 2014 at 13:55

3 Answers 3

1

Why didn't you do the following like you did your first example:

query = query.Include ("playerName");

you just have -

query.Include ("playerName");
Sign up to request clarification or add additional context in comments.

Comments

0

One solution would be to ensure that your ParseUser object is properly fetched. ie:

var obj = item.Get<ParseUser>("playerName");
Task t = obj.FetchIfNeededAsync();
while (!t.IsCompleted) yield return null;

Then you can do this without worrying:

string name = obj.Get<string>("profile");

But that will be another potential request to Parse, which is unfortunate. It seems that query.Include ("playerName") isn't properly working in the Unity version of Parse?

1 Comment

Thank you so much! but what shoud I do to do that? because I wanna get data from User object!
0

I believe you're supposed to use multi-level includes for this, like .Include("parent.playerName") in your first query.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.