static IEnumerable <T> CastResultContent <T>(ProvisioningQueryResult result, ProvisioningQueryResultType expected) { if (result.Type != expected) { throw new InvalidCastException($"result type is {result.Type}"); } // TODO: optimize this 2nd parse from JObject to target object type T return(result.Items.Select(o => ((JObject)o).ToObject <T>())); }
async Task <IEnumerable <T> > GetAndCastNextResultAsync <T>(ProvisioningQueryResultType type, QueryOptions options) { ProvisioningQueryResult r = await this.GetNextAsync(options); return(CastResultContent <T>(r, type)); }