Loading Objects in Relations

public class Person { public string Name { get; set; } public Address[] PersonAddress { get; set; } }

public class Address
{
public string StreetName { get; set; }
public string City { get; set; }

}I have Person table and Column PersonAddress relates to Address table (1:N). This is how i am retrieving the data

BackendlessAPI.Persistence.BackendlessDataQuery query = new BackendlessAPI.Persistence.BackendlessDataQuery();
QueryOptions queryOptions = new QueryOptions();
queryOptions.Related = new List<String>();
queryOptions.Related.Add(“PersonAddress”);
queryOptions.Related.Add(“PersonAddress.Address”);
//BackendlessCollection<Person> person = Backendless.Persistence.Of<Person>().Find(query); //Tried this
BackendlessCollection<Person> person = Backendless.Data.Of<Person>().Find(query); // Tried this

throwing Object not set for instance of object error
replaced above queryOptions with relationsDepth
queryOptions.RelationsDepth = 2;
Worked fine

Question: Why is my first method did not work?

Backendless.Persistence and Backendless.Data are identical. Both point to the same object. It is impossible that one would work and the other would not.

Regards,
Mark

How about this, what am i doing wrong.

QueryOptions queryOptions = new QueryOptions();
queryOptions.Related = new List<String>();
queryOptions.Related.Add(“PersonAddress”);
queryOptions.Related.Add(“PersonAddress.Address”);

BackendlessCollection<Person> person = Backendless.Persistence.Of<Person>().Find(query)
I am getting Object reference exception

Did you call query.setQueryOptions( queryOptions )?

Which line gives you the exception?

Mark