All pages
Powered by GitBook
1 of 1

Loading...

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:

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:

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:

ParallelRowFilter

Filters rows in parallel based on the provided predicate.

Parameters:

  • predicate: A function to filter rows.

Example:

ColumnNullOrEmptyFilter

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

Parameters:

  • row: The data row.

  • column: The column name.

Example:

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.

Example:

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.

Example:

RequiredColumns

Checks if the specified columns exist.

Parameters:

  • ColNames: The column names.

Example:

RequiredColumnsOR

Checks if at least one of the specified column exists.

Parameters:

  • ColNames: The column names.

Example:

AnyColumnsOfType

Checks if any columns exist of the specified types.

Parameters:

  • type: The types to check for.

Example:

ColumnsOfType

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

Parameters:

  • type: The types to check for.

Example:

ColumnExists

Checks if a column exists.

Parameters:

  • name: The name of the column.

Example:

ColumnName

Gets the column name from the target column name.

Parameters:

  • name: The target field name.

Example:

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.

Example:

ToClassList

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

Parameters:

  • filterNull: If true, filters out null converted items.

Example:

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:

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:

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:

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:

DataSet Methods (ONLY valid in set level transforms)

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.

Example:

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.

Example:

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.

Example:

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.

Example:

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.

Example:

ForEachSet

Iterates over each set looking them up by original name.

  • Parameters:

    • originalName (string): Original name.

    • Callback (Action): Callback per set.

Example:

FilterNulls: If true, no callback is given on null values.
  • col: A callback function.

  • col: A callback function.
    uncleanColumnNames: Outputs the list of names of the columns that failed to convert.
    names (string[]): Names of the sets.
  • Returns: A boolean indicating whether all specified sets are present.

  • SourceOnly (bool): If true, only source (untransformed) tables are considered. Default is false.
  • Returns: A boolean indicating whether the specified set is present.

  • SourceOnly (bool): If true, only source (untransformed) tables are considered. Default is false.
  • Returns: A list of DataTable objects for the specified sets.

  • SourceOnly (bool): If true, only source (untransformed) tables are considered. Default is false.
  • Returns: A list of TransformDataContext objects for the specified 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.

  • TransformedOnly (bool): If true, only transformed tables are considered.
  • SourceOnly (bool): If true, only source (untransformed) tables are considered. Default is false.

  • 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);
    Func<bool> isValid = () => true;
    Action<DataTable> dataProcessor = table => Console.WriteLine(table.Rows.Count);
    
    data.ProcessTable(isValid, dataProcessor);
    Func<bool> isValid = () => true;
    Action<DataRow, bool, MyClass> dataProcessor = (row, clean, myClass) => Console.WriteLine(myClass);
    
    data.ProcessRowsOfClass<MyClass>(isValid, dataProcessor);
    Func<DataRow, bool> predicate = row => row.Field<int>("ID") > 10;
    
    var filteredRows = data.ParallelRowFilter(predicate);
    var isNullOrEmpty = data.ColumnNullOrEmptyFilter(row, "ColumnName");
    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);
    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);
    bool allExist = data.RequiredColumns("Column1", "Column2");
    var columnsExist = data.RequiredColumnsOR("Column1", "Column2");
    bool columnsExist = data.AnyColumnsOfType(typeof(int), typeof(string));
    var columns = data.ColumnsOfType(typeof(int), typeof(string));
    bool exists = data.ColumnExists("ColumnName");
    string columnName = data.ColumnName("TargetFieldName");
    MyClass myClass = data.ToClass<MyClass>(row, out bool clean, out var uncleanColumnNames);
    var classList = data.ToClassList<MyClass>();
    bool success = data.GetValue<int>(row, "ColumnName", out int value);
    bool success = data.SetAndValidateValue(row, "ColumnName", value);
    bool success = data.SetAndValidateValueOrReport(row, "ColumnName", value);
    bool valid = data.ValidateValue("ColumnName", value);
    bool allSetsPresent = data.ContainsAssociatedSets(true, false, "set1", "set2");
    bool isSetPresent = data.ContainsAssociatedSet("set1", true);
    List<DataTable> sets = data.AssociatedSets("set1", true, false);
    List<TransformDataContext> contexts = data.DataContextFromSet("set1", true, false);
    var classData = data.SetToClass<MyClass>("set1", true, false, true);
    data.ForEachSet("set1", table => {
        // Handle each table
    }, true, false);