Hi, since SubtypeSublayer cannot be queried, Esri suggested querying the parent SubtypeFeatureLayer in answer . Is there a way to get the SubtypeSublayer's parent SubtypeFeatureLayer from the SubtypeSublayer ? SubtypeSublayers in the JavaScript SDK has a parent property doc . But I couldn't find a similar property in the .NET Maps SDK.
Thanks.
Solved! Go to Solution.
There is currently no way from SubtypeSublayer to get to its parent layer. But if you have a feature from an identify or query, this feature has reference to the table, and the table has reference to the layer it comes from.
As for the SubtypeSublayer.Id, in the Native SDKs this is meant to match the Subtype.code property. If you are using search.layer | Web Map Specification | Esri Developer, I think there's an optional subLayer property that will match SubtypeSublayer.Id.
The "id" on this search is a string so it will not match the sublayer. There is however, a SubtypeSublayer.unsupportedJSON property that is deprecated and will be removed in the next release that contains the "id" string. JSON on the left can be web/mobile map, watch window on the right is from map loaded in Native SDK for .NET.
The query operations are on the FeatureLayer.featureTable property. ArcGISFeatureTable, you can use the Sublayer's subtype code as additional filter in your where clause or use SubtypeSubtable.
Whether you're getting SubtypeFeatureLayer from web map or table that supports subtype, you can try the following code. Notice that for "Service Station" subtype (code: 21) on a Pipeline Device there's only 1 feature of this subtype out of 31411 features.
var credential = await AccessTokenCredential.CreateAsync(new Uri("https://sampleserver7.arcgisonline.com/portal/sharing/rest"), "viewer01", "I68VGU^nMurF");
AuthenticationManager.Current.AddCredential(credential);
var geodatabase = new ServiceGeodatabase(new Uri("https://sampleserver7.arcgisonline.com/server/rest/services/UtilityNetwork/NapervilleGasV6/FeatureServer"));
await geodatabase.LoadAsync();
var table = geodatabase.GetTable(0);
var layer = new SubtypeFeatureLayer(table);
await layer.LoadAsync();
var sublayer = layer.SubtypeSublayers.LastOrDefault();
ArgumentNullException.ThrowIfNull(sublayer);
var query = new QueryParameters();
query.WhereClause = $"{table.SubtypeField} = {sublayer.Subtype.Code}";
ArgumentNullException.ThrowIfNull(layer.FeatureTable);
var features = await layer.FeatureTable.QueryFeaturesAsync(query);
var subtypeTable = new SubtypeSubtable(sublayer.Subtype);
table.SubtypeSubtables.Add(subtypeTable);
var subtypeFeatures = await subtypeTable.QueryFeaturesAsync(new QueryParameters() { WhereClause = "1=1" });
var count = await layer.FeatureTable.QueryFeatureCountAsync(new QueryParameters() { WhereClause = "1=1" });
Hm, there is no back-reference to the parent layer from SubtypeSublayer though. Can you describe your workflow, how you have access to the sublayer only but not have access to the layer?
Thank you for the quick response @JenniferNery !
In your snippet I see the code has a reference to both the SubtypeSublayer and the SubtypeFeatureLayer. If I only have a reference to the SubtypeSublayer, is it not possible to obtain the SubtypeFeatureLayer it belongs to via a 'parent' property ?
Also comparing to the web SDK. I notice in web, SubtypeSublayer's Id field is a unique string, and a number like '2' as the subtype code. But in the .NET SDK, the Id property is just the subtype code '2'.
I'm trying to either access the SubtypeFeatureLayer through the SubtypeSublayer, or for the SubtypeSublayer to have an unique enough Id for the to search for in the Map.
There is currently no way from SubtypeSublayer to get to its parent layer. But if you have a feature from an identify or query, this feature has reference to the table, and the table has reference to the layer it comes from.
As for the SubtypeSublayer.Id, in the Native SDKs this is meant to match the Subtype.code property. If you are using search.layer | Web Map Specification | Esri Developer, I think there's an optional subLayer property that will match SubtypeSublayer.Id.
The "id" on this search is a string so it will not match the sublayer. There is however, a SubtypeSublayer.unsupportedJSON property that is deprecated and will be removed in the next release that contains the "id" string. JSON on the left can be web/mobile map, watch window on the right is from map loaded in Native SDK for .NET.