public override void ExecuteCmdlet()
{
// ValidationNotNullOrEmpty doesn't handle whitespaces well
if (Name != null && string.IsNullOrWhiteSpace(Name))
{
throw new PSArgumentNullException("Name");
}
if (ParameterSetName == ByFactoryObject)
{
if (DataFactory == null)
{
throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
}
DataFactoryName = DataFactory.DataFactoryName;
ResourceGroupName = DataFactory.ResourceGroupName;
}
DatasetFilterOptions filterOptions = new DatasetFilterOptions()
{
Name = Name,
ResourceGroupName = ResourceGroupName,
DataFactoryName = DataFactoryName
};
if (Name != null)
{
List<PSDataset> datasets = DataFactoryClient.FilterPSDatasets(filterOptions);
if (datasets != null && datasets.Any())
{
WriteObject(datasets[0]);
}
return;
}
// List datasets until all pages are fetched
do
{
WriteObject(DataFactoryClient.FilterPSDatasets(filterOptions), true);
} while (filterOptions.NextLink.IsNextPageLink());
}
}