Hi Jennifer, I managed to track down my issue and wanted to let you and others know in case they encounter a similar issue. Basically, the layers I add to the map come from a configuration, so we don't know what or how many runtime content geodatabases will exist. So, in the simple example I provided you, we might have parcels, property data and centerline. But, if you use the following code, QueryRelatedFeaturesAsync will never return the relationships (opening the Gdb from within the for loop):
var layerList = new Dictionary<string, string> {
{ "Parcels", "palmbeach.geodatabase" },
{"condodata", "palmbeach.geodatabase" },
{"CENTERLINE", "centerline.geodatabase" },
{"propertydata", "palmbeach.geodatabase" },
{"SITUS_PUB", "palmbeach.geodatabase" }
};
foreach (var layer in layerList) {
string gdbPath = Path.Combine (ConfigurationManager.AppSnapshotsDirectory, layer.Value);
gdbPath = PathHelpers.CleanPath (gdbPath);
var gdb = await Geodatabase.OpenAsync (gdbPath);
var table = gdb.GeodatabaseFeatureTable (layer.Key);
if (table != null) {
await table.LoadAsync ();
if (table.HasGeometry) {
EsriMapView.Map.OperationalLayers.Add (new FeatureLayer (table));
} else {
EsriMapView.Map.Tables.Add (table);
}
}
}
But, if you use the following code, which caches the geodatabase, then relationships will work:
var layerList = new Dictionary<string, string> {
{ "Parcels", "palmbeach.geodatabase" },
{"condodata", "palmbeach.geodatabase" },
{"CENTERLINE", "centerline.geodatabase" },
{"propertydata", "palmbeach.geodatabase" },
{"SITUS_PUB", "palmbeach.geodatabase" }
};
var gdbList = new Dictionary<string, Geodatabase> ();
Geodatabase gdb = null;
foreach (var layer in layerList) {
if (!gdbList.ContainsKey (layer.Value)) {
string gdbPath = Path.Combine (ConfigurationManager.AppSnapshotsDirectory, layer.Value);
gdbPath = PathHelpers.CleanPath (gdbPath);
gdb = await Geodatabase.OpenAsync (gdbPath);
gdbList.Add (layer.Value, gdb);
} else {
gdbList.TryGetValue (layer.Value, out gdb);
}
var table = gdb.GeodatabaseFeatureTable (layer.Key);
if (table != null) {
await table.LoadAsync ();
if (table.HasGeometry) {
EsriMapView.Map.OperationalLayers.Add (new FeatureLayer (table));
} else {
EsriMapView.Map.Tables.Add (table);
}
}
}
I guess I was thinking that the Geodatabase would be cached, but it doesn't appear to be the case. Is this expected behavior? Regardless, probably a bit better for performance this way so we don't have to open the geodatabase multiple times.