How to make a relationship query to an offline database?

3262
4
Jump to solution
12-15-2014 03:44 AM
JuhoVainio
Occasional Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor

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);

View solution in original post

0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor

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)

0 Kudos
JuhoVainio
Occasional Contributor

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?

0 Kudos
JenniferNery
Esri Regular Contributor

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);

0 Kudos
JuhoVainio
Occasional Contributor

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.

0 Kudos