What Changed
We added the following members to the IObjectLayerAsync interface: the CanLoadCollectionObjectsAsynchronously property and the LoadCollectionObjectsAsync method.
Reasons for Change
New members help us add the Task-based version of the XPBaseCollection.Load method. It is useful in scenarios where you want to asynchronously load XPCollection and then assign it to a data-bound control.
C#XPCollection<Customer> customers = new XPCollection<Customer>(session);
await customers.LoadAsync();
gridControl.DataSource = customers;
Visual BasicDim customers As New XPCollection(Of Customer)(session)
Await customers.LoadAsync()
gridControl.DataSource = customers
Impact on Existing Apps
This change will not affect the majority of XPO users.
Advanced XPO developers who created a custom Object Access Layer and implemented the IObjectLayerAsync interface, can extend their implementation as follows:
- The CanLoadCollectionObjectsAsynchronously property should return false if a custom Object Access Layer does not support the LoadCollectionObjectsAsync method.
- The LoadCollectionObjectsAsync method should return a task that represents asynchronous loading of collection properties. The task result must contain an array of collection objects.