Skip to content

Two Steps Retrieval

Important

Two Step Retrieval loads only a partial set of the related objects (default size of the retrieved related collection is 10). To load additional related objects, use the Relation Paging API .

With this approach a collection of related objects for a specific relation property in a parent object is retrieved from the server. The client application must know parent object's objectId. The API loads a collection of related children for one property at a time. Child objects retrieved in paged sets, see the Relation Paging API sectionfor additional details.

Suppose the Person table has a one-to-many relationship column friends pointing to the Users table. The code below retrieves related BackendlessUser objects for a specific Person object:

Prepare LoadRelationsQueryBuilder:

var loadRelationsQueryBuilder = LoadRelationsQueryBuilder<Dictionary<String, Object>>.Create();
loadRelationsQueryBuilder.SetRelationName( "friends" );
Blocking call:
String parentObjectId = // removed for brevity
var friends = Backendless.Data.Of( "Person" ).LoadRelations( parentObjectId, 
                                                             loadRelationsQueryBuilder );
foreach( var friend in friends )
  System.Console.WriteLine( friend[ "email" ]);
Non-blocking call:
String parentObjectId = // removed for brevity
var task = Backendless.Data.Of( "Person" ).LoadRelationsAsync( parentObjectId, 
                                                               loadRelationsQueryBuilder );
task.Wait();
var friends = task.Result;

foreach( var friend in friends )
  System.Console.WriteLine( friend[ "email" ] );

Prepare LoadRelationsQueryBuilder:

var loadRelationsQueryBuilder = LoadRelationsQueryBuilder<BackendlessUser>.Create();
loadRelationsQueryBuilder.SetRelationName( "friends" );
Blocking call:
String parentObjectId = ""; // removed for brevity
var friends = Backendless.Data.Of<Person>().LoadRelations( parentObjectId, 
                                                           loadRelationsQueryBuilder );
foreach( var friend in friends )
  System.Console.WriteLine( friend.Email );
Non-blocking call:
String parentObjectId = ""; // removed for brevity
var task = Backendless.Data.Of<Person>().LoadRelationsAsync( parentObjectId, 
                                                                loadRelationsQueryBuilder );
task.Wait();
var friends = task.Result;

foreach( var friend in friends )
  System.Console.WriteLine( friend.Email );