public async IAsyncEnumerable <T> DownloadAsync(string?whereClause = null, string?extraParameters = null, bool keepQuerying = false) { var featureSet = await Esri.GetFeatureSet(Url, Token, typeof(T).HasGeometry(), LayerInfo.hasZ, whereClause, extraParameters, null); foreach (var graphic in featureSet.features) { yield return(graphic.ToFeature <T>(LayerInfo)); } var objectIds = featureSet.features.Select(g => g.attributes[LayerInfo.GetObjectIdFieldName()].GetInt32()).ToArray(); if (!keepQuerying || objectIds.Length == 0) { yield break; } var oidSet = await Esri.GetOIDSet(Url, Token, whereClause, extraParameters); var remainingObjectIds = oidSet.objectIds.Except(objectIds); await foreach (var feature in DownloadAsync(remainingObjectIds, whereClause, extraParameters, LayerInfo.maxRecordCount ?? objectIds.Length)) { yield return(feature); } }
public IEnumerable <T> Download(string?whereClause = null, string?extraParameters = null, bool keepQuerying = false, int degreeOfParallelism = 1, CancellationToken?cancellationToken = null) { var featureSet = Esri.GetFeatureSet(Url, Token, typeof(T).HasGeometry(), LayerInfo.hasZ, whereClause, extraParameters, null).Result; foreach (var g in featureSet.features) { yield return(g.ToFeature <T>(LayerInfo)); } var objectIds = featureSet.features.Select(g => g.attributes[LayerInfo.GetObjectIdFieldName()].GetInt32()).ToArray(); if (!keepQuerying || objectIds.Length == 0) { yield break; } var remainingObjectIds = Esri.GetOIDSet(Url, Token, whereClause, extraParameters).Result.objectIds.Except(objectIds); foreach (var f in Download(remainingObjectIds, whereClause, extraParameters, LayerInfo.maxRecordCount ?? objectIds.Length, degreeOfParallelism, cancellationToken)) { yield return(f); } }