private async Task GetDeviceTwins(string tenantId, string query, string continuationToken, List <TwinServiceModel> twins)
        {
            DeviceServiceListModel devices = null;

            devices = await this.GetListAsync(tenantId, query, null);

            if (devices != null && devices.Items.Count() > 0)
            {
                twins.AddRange(devices.Items.Select(i => i.Twin));
                if (!string.IsNullOrWhiteSpace(devices.ContinuationToken))
                {
                    await this.GetDeviceTwins(tenantId, query, continuationToken, twins);
                }
            }
        }
        private async Task <DeviceServiceListModel> GetListAsync(string tenantId, string query, string continuationToken)
        {
            var twins = await this.GetTwinByQueryAsync(
                tenantId,
                QueryPrefix,
                query,
                continuationToken,
                1000);

            var connectedEdgeDevices = await this.GetConnectedEdgeDevices(tenantId, twins.Result);

            var resultModel = new DeviceServiceListModel(
                twins.Result.Select(azureTwin => new DeviceServiceModel(
                                        azureTwin,
                                        string.Empty,
                                        connectedEdgeDevices.ContainsKey(azureTwin.DeviceId))),
                twins.ContinuationToken);

            return(resultModel);
        }