I have created a database replica for offline use. I would like to make a relationship query to the offline geodatabase. How can I do this?
I've found documentation on how to do a basic query to a table and it's very simple (just table.Query()). However, the QueryRelatedAsync method requires the RelationshipID. How is the ID aquired if the app is in offline mode and doesn't have access to the feature server? There doesn't seem to be any documentation on the offline relationship query.
Solved! Go to Solution.
Similar to the sample, you have to get service metadata for the table. But instead of GetDetails, you use ServiceInfo. Also, similar to the sample when you query relationship, you will need to provide the feature id and relationship id.
Something like this..
var geodatabase = await Geodatabase.OpenAsync(filePath);
var layer = new FeatureLayer(geodatabase.GetFeatureTableById(0));
var table = (ArcGISFeatureTable)layer.FeatureTable;
var relationshipID = table.ServiceInfo.Relationships[0].ID;
var results = await table.QueryRelatedAsync(featureID, relationshipID);
You can look at this SDK sample : arcgis-runtime-samples-dotnet/EditRelatedData.xaml.cs at master · Esri/arcgis-runtime-samples-dotnet...
Although sample use QueryTask (online), similar parameters can be used to access related data off ArcGISFeatureTable. Just note that when you generate the geodatabase, you must also request for the related table. ArcGISFeatureTable.QueryRelatedAsync Method (Boolean, Int64)
Thanks for the reply, but this doesn't really answer the question. I looked at the sample and it uses the layers to get the relationship id. Also it uses ArcGISDynamicMapServiceLayer which I also don't have as I'm offline.
I only have a .geodatabase and I need to query data from tables. I know I can get the tables from the gdb with lambda expressions easily, but again: how do I get the relationshipId required in the QueryRelatedAsync method?
Similar to the sample, you have to get service metadata for the table. But instead of GetDetails, you use ServiceInfo. Also, similar to the sample when you query relationship, you will need to provide the feature id and relationship id.
Something like this..
var geodatabase = await Geodatabase.OpenAsync(filePath);
var layer = new FeatureLayer(geodatabase.GetFeatureTableById(0));
var table = (ArcGISFeatureTable)layer.FeatureTable;
var relationshipID = table.ServiceInfo.Relationships[0].ID;
var results = await table.QueryRelatedAsync(featureID, relationshipID);
So even when the table is an offline table, I must use the ServiceInfo...? It's a bit confusing since we don't have any services in offline mode.