# TransformDataContext

### ProcessRows

Processes each row in the table using the provided filter predicate and data processor actions.

Parameters:

* `isValid`: A function that returns a boolean indicating if the process is valid.
* `FilterPredicate`: A function to filter input rows.
* `DataProcessor`: An action to process each row.

#### Example:

```csharp
Func<bool> isValid = () => true;
Func<DataRow, bool> filterPredicate = row => row.Field<int>("ID") > 10;
Action<DataRow, long> dataProcessor = (row, index) => Console.WriteLine(row);

data.ProcessRows(isValid, filterPredicate, dataProcessor);
```

### ProcessTable

Processes the entire table using the provided data processor action.

Parameters:

* `isValid`: A function that returns a boolean indicating if the process is valid.
* `DataProcessor`: An action to process the table.

#### Example:

```csharp
Func<bool> isValid = () => true;
Action<DataTable> dataProcessor = table => Console.WriteLine(table.Rows.Count);

data.ProcessTable(isValid, dataProcessor);
```

### ProcessRowsOfClass

Processes each row of the table by converting it to a target class. It sends non-null rows to the data processor.

Parameters:

* `isValid`: A function that returns a boolean indicating if the process is valid.
* `DataProcessor`: An action to process each row.

#### Example:

```csharp
Func<bool> isValid = () => true;
Action<DataRow, bool, MyClass> dataProcessor = (row, clean, myClass) => Console.WriteLine(myClass);

data.ProcessRowsOfClass<MyClass>(isValid, dataProcessor);
```

### ParallelRowFilter

Filters rows in parallel based on the provided predicate.

Parameters:

* `predicate`: A function to filter rows.

#### Example:

```csharp
Func<DataRow, bool> predicate = row => row.Field<int>("ID") > 10;

var filteredRows = data.ParallelRowFilter(predicate);
```

### ColumnNullOrEmptyFilter

Checks if a column value in a row is null or empty.

Parameters:

* `row`: The data row.
* `column`: The column name.

#### Example:

```csharp
var isNullOrEmpty = data.ColumnNullOrEmptyFilter(row, "ColumnName");
```

### EachColumnWithType

Iterates over each column and uses the callback if the column type is valid.

Parameters:

* `row`: The data row.
* `columns`: A dictionary of column names and boolean values.
* `t`: The type to validate.
* `FilterNulls`: If true, no callback is given on null values.
* `col`: A callback function.

#### Example:

```csharp
Dictionary<string, bool> columns = new Dictionary<string, bool> { { "Column1", true }, { "Column2", false } };
Type type = typeof(string);
Action<string, string, bool> callback = (colName, value, isNull) => Console.WriteLine($"{colName}: {value}");

data.EachColumnWithType(row, columns, type, callback);
```

### EachColumn

Iterates over each column in the dictionary and casts the value to the specified type.

Parameters:

* `row`: The data row.
* `columns`: A dictionary of column names and boolean values.
* `FilterNulls`: If true, no callback is given on null values.
* `col`: A callback function.

#### Example:

```csharp
Dictionary<string, bool> columns = new Dictionary<string, bool> { { "Column1", true }, { "Column2", false } };
Action<string, string, bool> callback = (colName, value, isNull) => Console.WriteLine($"{colName}: {value}");

data.EachColumn<string>(row, columns, callback);
```

### RequiredColumns

Checks if the specified columns exist.

Parameters:

* `ColNames`: The column names.

#### Example:

```csharp
bool allExist = data.RequiredColumns("Column1", "Column2");
```

### RequiredColumnsOR

Checks if at least one of the specified column exists.

Parameters:

* `ColNames`: The column names.

#### Example:

```csharp
var columnsExist = data.RequiredColumnsOR("Column1", "Column2");
```

### AnyColumnsOfType

Checks if any columns exist of the specified types.

Parameters:

* `type`: The types to check for.

#### Example:

```csharp
bool columnsExist = data.AnyColumnsOfType(typeof(int), typeof(string));
```

### ColumnsOfType

Returns a list of columns that are of the specified types.

Parameters:

* `type`: The types to check for.

#### Example:

```csharp
var columns = data.ColumnsOfType(typeof(int), typeof(string));
```

### ColumnExists

Checks if a column exists.

Parameters:

* `name`: The name of the column.

#### Example:

```csharp
bool exists = data.ColumnExists("ColumnName");
```

### ColumnName

Gets the column name from the target column name.

Parameters:

* `name`: The target field name.

#### Example:

```csharp
string columnName = data.ColumnName("TargetFieldName");
```

### ToClass

Converts a data row to a specified class.

Parameters:

* `r`: The data row.
* `UseTargetFieldName`: If true, maps through the mapping specification.
* `Clean`: Outputs if the row could be completely converted.
* `uncleanColumnNames`: Outputs the list of names of the columns that failed to convert.

#### Example:

```csharp
MyClass myClass = data.ToClass<MyClass>(row, out bool clean, out var uncleanColumnNames);
```

### ToClassList

Converts the entire data table to a list of specified classes.

Parameters:

* `filterNull`: If true, filters out null converted items.

#### Example:

```csharp
var classList = data.ToClassList<MyClass>();
```

### GetValue

Gets a value from a data row by the map target name and converts it to the specified type.

Parameters:

* `row`: The data row.
* `name`: The name of the target column.
* `val`: Outputs the value.

#### Example:

```csharp
bool success = data.GetValue<int>(row, "ColumnName", out int value);
```

### SetAndValidateValue

Sets and validates a value of a row.

Parameters:

* `row`: The data row.
* `column`: The target column name.
* `val`: The value to set.

#### Example:

```csharp
bool success = data.SetAndValidateValue(row, "ColumnName", value);
```

### SetAndValidateValueOrReport

Sets and validates a value of a row and generates a report if it fails.

Parameters:

* `row`: The data row.
* `column`: The target column name.
* `val`: The value to set.

#### Example:

```csharp
bool success = data.SetAndValidateValueOrReport(row, "ColumnName", value);
```

### ValidateValue

Validates that a new value is valid against the map restrictions for any given column.

Parameters:

* `columnName`: The name of the column.
* `value`: The value to validate.

#### Example:

```csharp
bool valid = data.ValidateValue("ColumnName", value);
```

## DataSet Methods <mark style="color:red;">(ONLY valid in set level transforms)</mark>

### ContainsAssociatedSets

Checks if all specified data sets are present.

* **Parameters:**
  * `TransformOnly` (bool): If true, only transformed tables are returned. Default is true.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.
  * `names` (string\[]): Names of the sets.
* **Returns:** A boolean indicating whether all specified sets are present.

#### Example:

```csharp
bool allSetsPresent = data.ContainsAssociatedSets(true, false, "set1", "set2");
```

### ContainsAssociatedSet

Checks if a specified data set is present.

* **Parameters:**
  * `name` (string): Name of the set.
  * `TransformOnly` (bool): If true, only transformed tables are returned. Default is true.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.
* **Returns:** A boolean indicating whether the specified set is present.

#### Example:

```csharp
bool isSetPresent = data.ContainsAssociatedSet("set1", true);
```

### AssociatedSets

Retrieves all associated data sets by name.

* **Parameters:**
  * `name` (string): Name of the set.
  * `TransformOnly` (bool): If true, only transformed tables are returned. Default is true.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.
* **Returns:** A list of `DataTable` objects for the specified sets.

#### Example:

```csharp
List<DataTable> sets = data.AssociatedSets("set1", true, false);
```

### DataContextFromSet

Creates a data context from a set name.

* **Parameters:**
  * `name` (string): Original table names from the set.
  * `TransformOnly` (bool): If true, only the transformed tables are considered.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.
* **Returns:** A list of `TransformDataContext` objects for the specified sets.

#### Example:

```csharp
List<TransformDataContext> contexts = data.DataContextFromSet("set1", true, false);
```

### SetToClass

Converts the first available set to an enumerable of a specified type.

* **Parameters:**
  * `T` (type): Type to which the set will be converted.
  * `originalName` (string): Original name of the transform sets.
  * `TransformedOnly` (bool): If true, only transformed tables are returned. Default is true.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.
  * `filterNull` (bool): If true, will filter out null rows. Default is false.
* **Returns:** An enumerable of tuples containing the data of type `T`, a boolean indicating cleanliness, and a list of unclean column names.

#### Example:

```csharp
var classData = data.SetToClass<MyClass>("set1", true, false, true);
```

### ForEachSet

Iterates over each set looking them up by original name.

* **Parameters:**
  * `originalName` (string): Original name.
  * `Callback` (Action): Callback per set.
  * `TransformedOnly` (bool): If true, only transformed tables are considered.
  * `SourceOnly` (bool): If true, only source (untransformed) tables are considered. Default is false.

#### Example:

```csharp
data.ForEachSet("set1", table => {
    // Handle each table
}, true, false);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perigee.software/transform-sdk/sdk-reference/transformdatacontext.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
