Developer

Read Operations

Perform Read operations on an ODataEntity or an ODataEntitySet from OData or JSON service connections.

Context

Read operation process flow:

Steps 1 and 2 are called only once, when the application starts.

Procedure

  1. Create an instance of Online ODataStore, as described in Initializing an Online Store.
  2. Call OpenAsync by passing in the instance of SAP.Net.Http.HttpClient.
    1. Create an instance SAP.Net.Http.HttpClient.
    2. Pass in System.Net.Http.HttpClientHandler in the constructor to pass in the credentials.
    3. Use SAP.Net.Http.HttpClient to pass in the headers (for example, X-SUP-APPCID).
    var client = new SAP.Net.Http.HttpClient(
        new System.Net.Http.HttpClientHandler { Credentials = new NetworkCredential(“user", “password") }, true);
    client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID",appconnid);
    
    await store.OpenAsync(client);
    
  3. Call ScheduleReadEntitySet passing in the collection name:
    // Read the collection and wait for the response
    // Note: The collection name can include filters. For example, Suppliers?$top=5
    var execution = store.ScheduleReadEntitySet(collectionName);
    IODataResponse response = await execution.Response;
    
    // Subsequent calls to read collections
    var execution = store.ScheduleReadEntitySet(anotherCollectionName);
    IODataResponse response = await execution.Response;

    The Response property is called asynchronously.