Group Defining Queries¶
Multiple defining queries can be grouped into one batch request when mobile services downloads the data from the OData back end. This can be accomplished by calling setDefiningQueryGroups
. The example below demonstrates how to group the defining queries.
offlineODataProvider.addDefiningQuery(
new OfflineODataDefiningQuery("Events_10000",
"/Events?$filter=EventID eq 10000L&$expand=Features",
false));
offlineODataProvider.addDefiningQuery(
new OfflineODataDefiningQuery("Sessions_10000",
"/Sessions?$filter=EventID eq 10000L",
false));
offlineODataProvider.addDefiningQuery(
new OfflineODataDefiningQuery("Tracks_10000",
"/Tracks?$filter=EventID eq 10000L",
false));
offlineODataProvider.addDefiningQuery(
new OfflineODataDefiningQuery("UserSessionAgendas",
"/UserSessionAgendas?$filter=EventID eq 10000L",
false));
List<Set<String>> groups = new ArrayList<>();
groups.add(new HashSet<String>(Arrays.asList(new String[]{"Events_10000, Sessions_10000"})));
groups.add(new HashSet<String>(Arrays.asList(new String[]{"Tracks_10000, UserSessionAgendas"})));
offlineODataProvider.setDefiningQueryGroups(groups);
try provider.add(definingQuery: OfflineODataDefiningQuery(name: "Events_10000",
query: "/Events?$filter=EventID eq 10000L&$expand=Features",
automaticallyRetrievesStreams: false))
try provider.add(definingQuery: OfflineODataDefiningQuery(name: "Sessions_10000",
query: "/Sessions?$filter=EventID eq 10000L",
automaticallyRetrievesStreams: false))
try provider.add(definingQuery: OfflineODataDefiningQuery(name: "Tracks_10000",
query: "/Tracks?$filter=EventID eq 10000L",
automaticallyRetrievesStreams: false))
try provider.add(definingQuery: OfflineODataDefiningQuery(name: "UserSessionAgendas",
query: "/UserSessionAgendas?$filter=EventID eq 10000L",
automaticallyRetrievesStreams: false))
let group1:Set<String> = ["Events_10000", "Sessions_10000"]
let group2:Set<String> = ["Tracks_10000", "UserSessionAgendas"]
try provider.setDefiningQueryGroups(groups: [group1, group2])
This can also be accomplished by modifying the application configuration file using the Offline editor in the mobile services cockpit. See defining_query_group
in Application Configuration File for further details. If both client-side coding and server-side configuration have been done, then the client-side coding will override the server-side configuration.
Last update: June 7, 2022