public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ParameterSetNames.ByFactoryObjectByRunId, StringComparison.OrdinalIgnoreCase) ||
                ParameterSetName.Equals(ParameterSetNames.ByFactoryObjectByPipeline, StringComparison.OrdinalIgnoreCase))
            {
                DataFactoryName   = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            if (ParameterSetName.Equals(ParameterSetNames.ByFactoryObjectByRunId, StringComparison.OrdinalIgnoreCase) ||
                ParameterSetName.Equals(ParameterSetNames.ByFactoryNameByRunId, StringComparison.OrdinalIgnoreCase))
            {
                WriteObject(DataFactoryClient.GetPipelineRun(ResourceGroupName, DataFactoryName, PipelineRunId));
            }
            else
            {
                PipelineRunFilterOptions runFilter = new PipelineRunFilterOptions
                {
                    ResourceGroupName = ResourceGroupName,
                    DataFactoryName   = DataFactoryName,
                    PipelineName      = PipelineName,
                    LastUpdatedAfter  = LastUpdatedAfter,
                    LastUpdatedBefore = LastUpdatedBefore
                };
                WriteObject(DataFactoryClient.ListPipelineRuns(runFilter));
            }
        }
        public virtual List <PSPipelineRun> ListPipelineRuns(PipelineRunFilterOptions pipelineRunFilter)
        {
            var pipelineRuns = new List <PSPipelineRun>();

            var runFilters = new RunFilterParameters()
            {
                LastUpdatedAfter  = pipelineRunFilter.LastUpdatedAfter,
                LastUpdatedBefore = pipelineRunFilter.LastUpdatedBefore,
                Filters           = new List <RunQueryFilter>(),
                OrderBy           = new List <RunQueryOrderBy>(),
            };

            if (pipelineRunFilter.PipelineName != null)
            {
                runFilters.Filters.Add(
                    new RunQueryFilter()
                {
                    Operand          = RunQueryFilterOperand.PipelineName,
                    OperatorProperty = RunQueryFilterOperator.Equals,
                    Values           = new List <string>()
                    {
                        pipelineRunFilter.PipelineName
                    }
                });
            }
            else if (pipelineRunFilter.Filters != null)
            {
                runFilters.Filters = pipelineRunFilter.Filters;
            }

            if (pipelineRunFilter.OrderBy != null)
            {
                runFilters.OrderBy = pipelineRunFilter.OrderBy;
            }
            else
            {
                runFilters.OrderBy.Add(
                    new RunQueryOrderBy()
                {
                    Order   = RunQueryOrder.DESC,
                    OrderBy = RunQueryOrderByField.RunEnd
                });
            }

            PipelineRunsQueryResponse response = this.DataFactoryManagementClient.PipelineRuns.QueryByFactory(pipelineRunFilter.ResourceGroupName, pipelineRunFilter.DataFactoryName, runFilters);

            pipelineRuns.AddRange(response.Value.Select(pr =>
                                                        new PSPipelineRun(pr, pipelineRunFilter.ResourceGroupName, pipelineRunFilter.DataFactoryName)));

            string continuationToken = response.ContinuationToken;

            while (!string.IsNullOrWhiteSpace(continuationToken))
            {
                runFilters.ContinuationToken = continuationToken;
                response = this.DataFactoryManagementClient.PipelineRuns.QueryByFactory(pipelineRunFilter.ResourceGroupName, pipelineRunFilter.DataFactoryName, runFilters);

                pipelineRuns.AddRange(response.Value.Select(pr =>
                                                            new PSPipelineRun(pr, pipelineRunFilter.ResourceGroupName, pipelineRunFilter.DataFactoryName)));

                continuationToken = response.ContinuationToken;
            }
            return(pipelineRuns);
        }