Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query relational data using subclasses? parse.com and Unity

Im trying to query all elements of subclass in Unity. I have found SDK constraint or missing something here. According to documentation querying subclasses is possible.

> var query = new ParseQuery<Armor>()
    .WhereLessThanOrEqualTo("rupees", ((Player)ParseUser.CurrentUser).Rupees);
query.FindAsync().ContinueWith(t =>
{
    IEnumerable<Armor> result = t.Result;
});

Im however using relation table and cannot specify Here is my code:

IEnumerator LoadMyDesigns(Action<RequestResult> result) {

    ParseUser user = ParseUser.CurrentUser;
    ParseRelation<Design> relation = user.GetRelation<Design>("designs");
    Task<IEnumerable<Design>> task = relation.Query.FindAsync();


    while (!task.IsCompleted) yield return new WaitForEndOfFrame();

    if (task.IsFaulted) {
        //error
        foreach(var e in task.Exception.InnerExceptions) {
            ParseException parseException = (ParseException) e;
            Debug.LogError("Error message " + parseException.Message);
            Debug.LogError("Error code: " + parseException.Code);
            result(new RequestResult(true, parseException.Message));
        }
    }
    else {
        result(new RequestResult(true, new List<Design>(task.Result)));
    }
}

And error:

ArgumentNullException: Must specify a ParseObject class name when creating a ParseQuery.

So the question is how do I specify query subclass type when using relations?

Thanks.

like image 326
Greg Lukosek Avatar asked May 27 '26 19:05

Greg Lukosek


1 Answers

I've struggled with the same problem and in my case I needed to provide the propertyName again in de GetRelationProperty call.

For example:

[ParseFieldName("designs")]
public ParseRelation<Design> Designs
{
    get { return GetRelationProperty<Design>("Designs"); }
}
like image 78
Dylan Schoenmakers Avatar answered May 30 '26 09:05

Dylan Schoenmakers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!