public override void ExecuteCmdlet()

in src/Modules/Data/Commands.Data/GetPowerBIDataset.cs [98:156]


        public override void ExecuteCmdlet()
        {
            if(this.Workspace != null)
            {
                this.WorkspaceId = this.Workspace.Id;
            }

            if (this.Id != default)
            {
                this.Filter = $"id eq '{this.Id}'";
            }

            if (this.Name != default)
            {
                this.Filter = $"tolower(name) eq '{this.Name.ToLower()}'";
            }

            IEnumerable<Dataset> datasets = null;
            using (var client = this.CreateClient())
            {
                if(this.WorkspaceId != default)
                {
                    datasets = this.Scope == PowerBIUserScope.Individual ?
                        client.Datasets.GetDatasetsForWorkspace(this.WorkspaceId, this.Include) :
                        client.Datasets.GetDatasetsAsAdminForWorkspace(this.WorkspaceId, filter: this.Filter, top: this.First, skip: this.Skip, expand: this.Include);
                }
                else
                {
                    datasets = this.Scope == PowerBIUserScope.Individual ?
                        client.Datasets.GetDatasets(this.Include) :
                        client.Datasets.GetDatasetsAsAdmin(filter: this.Filter, top: this.First, skip: this.Skip, expand: this.Include);
                }
            }

            if (this.Scope == PowerBIUserScope.Individual)
            {
                if (this.Id != default)
                {
                    datasets = datasets?.Where(d => this.Id == d.Id);
                }

                if (!string.IsNullOrEmpty(this.Name))
                {
                    datasets?.Where(d => d.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
                }

                if (this.Skip.HasValue)
                {
                    datasets = datasets?.Skip(this.Skip.Value);
                }

                if (this.First.HasValue)
                {
                    datasets = datasets?.Take(this.First.Value);
                }
            }

            this.Logger.WriteObject(datasets, true);
        }