Class DataRowExtensions
Data row extension methods
Inherited Members
Namespace: PayrollEngine.Client.Scripting.Report
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public static class DataRowExtensions
Methods
View SourceAsDictionary(DataRow)
Get data row values as dictionary
Declaration
public static Dictionary<string, object> AsDictionary(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| Dictionary<string, object> | The data rows values as dictionary, key is the column name |
GetAttribute(DataRow, string, object)
Get value from attributes column
Declaration
public static object GetAttribute(this DataRow dataRow, string attribute, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | attribute | The attribute name |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| object | The attribute value |
GetAttribute(DataRow, string, string, object)
Get attribute from a data row json value
Declaration
public static object GetAttribute(this DataRow dataRow, string column, string attribute, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| string | attribute | The attribute name |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| object | The attribute value |
GetAttribute<T>(DataRow, string, string, T)
Get attribute from a data row json value
Declaration
public static T GetAttribute<T>(this DataRow dataRow, string column, string attribute, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| string | attribute | The attribute name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The attribute value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetAttribute<T>(DataRow, string, T)
Get value from attributes column
Declaration
public static T GetAttribute<T>(this DataRow dataRow, string attribute, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | attribute | The attribute name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The attribute value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetAttributes(DataRow)
Get attributes column value as attribute dictionary
Declaration
public static Dictionary<string, object> GetAttributes(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| Dictionary<string, object> | The attributes dictionary |
GetAttributes(DataRow, string)
Get data row json value as attribute dictionary
Declaration
public static Dictionary<string, object> GetAttributes(this DataRow dataRow, string column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
Returns
| Type | Description |
|---|---|
| Dictionary<string, object> | The attributes dictionary |
GetDictionary<TKey, TValue>(DataRow, string)
Get data row JSON value as dictionary
Declaration
public static Dictionary<TKey, TValue> GetDictionary<TKey, TValue>(this DataRow dataRow, string column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
Returns
| Type | Description |
|---|---|
| Dictionary<TKey, TValue> | The dictionary |
Type Parameters
| Name | Description |
|---|---|
| TKey | |
| TValue |
GetEnumValue<T>(DataRow, string, T)
Get data row enum value
Declaration
public static T GetEnumValue<T>(this DataRow dataRow, string column, T defaultValue = default) where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The data row enum value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetJsonValue(DataRow, string, Type, object)
Get data row json value
Declaration
public static object GetJsonValue(this DataRow dataRow, string column, Type type, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| Type | type | The value type |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| object | The data row value |
GetJsonValue<T>(DataRow, string, object)
Get data row json value
Declaration
public static T GetJsonValue<T>(this DataRow dataRow, string column, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The data row value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetListValue<T>(DataRow, string)
Get data row JSON value as list
Declaration
public static List<T> GetListValue<T>(this DataRow dataRow, string column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
Returns
| Type | Description |
|---|---|
| List<T> | The list |
Type Parameters
| Name | Description |
|---|---|
| T |
GetLocalization(DataRow, string, string, string)
Get attribute from a data row json value
Declaration
public static string GetLocalization(this DataRow dataRow, string column, string culture, string defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| string | culture | The culture |
| string | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| string | The attribute value |
GetLocalizations(DataRow, string)
Get data row json value as localizations dictionary
Declaration
public static Dictionary<string, string> GetLocalizations(this DataRow dataRow, string column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | The attributes dictionary |
GetLocalizedIdentifier(DataRow, string)
Get data row localized identifier
Declaration
public static string GetLocalizedIdentifier(this DataRow dataRow, string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | culture | The culture |
Returns
| Type | Description |
|---|---|
| string | The localized data row identifier |
GetLocalizedName(DataRow, string)
Get data row localized name
Declaration
public static string GetLocalizedName(this DataRow dataRow, string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | culture | The culture |
Returns
| Type | Description |
|---|---|
| string | The localized data row name |
GetLocalizedValue(DataRow, string, string)
Get data row localized value using the ValueColumnLocalizations column
Declaration
public static string GetLocalizedValue(this DataRow dataRow, string valueColumn, string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | valueColumn | The value column name |
| string | culture | The culture |
Returns
| Type | Description |
|---|---|
| string | The localized data row value |
GetLocalizedValue(DataRow, string, string, string)
Get data row localized value
Declaration
public static string GetLocalizedValue(this DataRow dataRow, string valueColumn, string localizationColumn, string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | valueColumn | The value column name |
| string | localizationColumn | The localization column name |
| string | culture | The culture |
Returns
| Type | Description |
|---|---|
| string | The localized data row value |
GetPayrollValue(DataRow, object)
Get default payroll value
Declaration
public static object GetPayrollValue(this DataRow dataRow, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| object | The payroll value |
GetPayrollValue(DataRow, string, string, object)
Get payroll value
Declaration
public static object GetPayrollValue(this DataRow dataRow, string valueColumn, string valueTypeColumn, object defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | valueColumn | The value column name |
| string | valueTypeColumn | The value type column name |
| object | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| object | The payroll value |
GetPayrollValueType(DataRow)
Get default payroll value type
Declaration
public static ValueType GetPayrollValueType(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| ValueType | The payroll value tye |
GetPayrollValueType(DataRow, string, ValueType)
Get payroll value type
Declaration
public static ValueType GetPayrollValueType(this DataRow dataRow, string column, ValueType defaultType = ValueType.String)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| ValueType | defaultType | The default value type |
Returns
| Type | Description |
|---|---|
| ValueType | The payroll value tye |
GetPayrollValue<T>(DataRow, string, string, T)
Get payroll value
Declaration
public static T GetPayrollValue<T>(this DataRow dataRow, string valueColumn, string valueTypeColumn, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | valueColumn | The value column name |
| string | valueTypeColumn | The value type column name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The payroll value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetPayrollValue<T>(DataRow, T)
Get default payroll value
Declaration
public static T GetPayrollValue<T>(this DataRow dataRow, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The payroll value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetValue<T>(DataRow, string, T)
Get data row value
Declaration
public static T GetValue<T>(this DataRow dataRow, string column, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The data row value |
Type Parameters
| Name | Description |
|---|---|
| T |
GetValues(IEnumerable<DataRow>)
Get data row values
Declaration
public static List<object> GetValues(this IEnumerable<DataRow> dataRows)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<DataRow> | dataRows |
Returns
| Type | Description |
|---|---|
| List<object> | The data rows values |
GetValues<T>(IEnumerable<DataRow>, string, T)
Get data rows value
Declaration
public static List<T> GetValues<T>(this IEnumerable<DataRow> dataRows, string column, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<DataRow> | dataRows | |
| string | column | The column name |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| List<T> | The data rows value |
Type Parameters
| Name | Description |
|---|---|
| T |
Id(DataRow)
Get data row id
Declaration
public static int Id(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| int | The data row id |
Identifier(DataRow)
Get data row identifier
Declaration
public static string Identifier(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| string | The data row identifier |
Json(DataRow, JsonNamingPolicy, bool)
Get data row as json
Declaration
public static string Json(this DataRow dataRow, JsonNamingPolicy namingPolicy = null, bool ignoreNull = true)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| JsonNamingPolicy | namingPolicy | Naming policy (default: camel case) |
| bool | ignoreNull | Ignore null values (default: true) |
Returns
| Type | Description |
|---|---|
| string |
Name(DataRow)
Get data row name
Declaration
public static string Name(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| string | The data row name |
ObjectStatus(DataRow)
Get data row object status
Declaration
public static ObjectStatus ObjectStatus(this DataRow dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow |
Returns
| Type | Description |
|---|---|
| ObjectStatus | The data row object status |
SetJsonValue(DataRow, string, object)
Set data row json value
Declaration
public static void SetJsonValue(this DataRow dataRow, string column, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| object | value | The value to set |
SetJsonValue<T>(DataRow, string, T)
Set data row json value
Declaration
public static void SetJsonValue<T>(this DataRow dataRow, string column, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| T | value | The value to set |
Type Parameters
| Name | Description |
|---|---|
| T |
SetValue(DataRow, string, object, Type)
Set data row value
Declaration
public static void SetValue(this DataRow dataRow, string column, object value, Type type = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| object | value | The value to set |
| Type | type | The value type |
SetValue<T>(DataRow, string, T)
Set data row value
Declaration
public static void SetValue<T>(this DataRow dataRow, string column, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| string | column | The column name |
| T | value | The value to set |
Type Parameters
| Name | Description |
|---|---|
| T |
TransposeFrom(DataRow, DataRow, Func<DataColumn, string>, Func<object, object>, Func<DataColumn, Type>, Func<DataColumn, object>)
Transpose data row items to table columns with values
Declaration
public static void TransposeFrom(this DataRow dataRow, DataRow source, Func<DataColumn, string> columnName = null, Func<object, object> itemValue = null, Func<DataColumn, Type> columnType = null, Func<DataColumn, object> defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| DataRow | source | The source data row |
| Func<DataColumn, string> | columnName | The column name function, default is the source column name |
| Func<object, object> | itemValue | The item value function, default is the source column value |
| Func<DataColumn, Type> | columnType | The column type function, default is the source column type |
| Func<DataColumn, object> | defaultValue | The default value function, default is none |
Remarks
Use the function return value null, to suppress further item operations
TransposeFrom<T>(DataRow, IEnumerable<T>, Func<T, string>, Func<T, object>, Func<T, Type>, Func<T, object>)
Transpose item collection to table columns with values
Declaration
public static void TransposeFrom<T>(this DataRow dataRow, IEnumerable<T> items, Func<T, string> columnName, Func<T, object> itemValue, Func<T, Type> columnType = null, Func<T, object> defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| IEnumerable<T> | items | The items to transpose |
| Func<T, string> | columnName | The column name function (mandatory) |
| Func<T, object> | itemValue | The item value function (mandatory) |
| Func<T, Type> | columnType | The column type function, default is string |
| Func<T, object> | defaultValue | The default value function, default is none |
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
Use the function return value null, to suppress further item operations
TransposeFrom<TKey, TValue>(DataRow, IDictionary<TKey, TValue>, Func<TKey, string>, Func<TValue, object>, Func<TKey, Type>, Func<TKey, object>)
Transpose dictionary to table columns with values
Declaration
public static void TransposeFrom<TKey, TValue>(this DataRow dataRow, IDictionary<TKey, TValue> items, Func<TKey, string> columnName = null, Func<TValue, object> itemValue = null, Func<TKey, Type> columnType = null, Func<TKey, object> defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRow | dataRow | |
| IDictionary<TKey, TValue> | items | The items to transpose |
| Func<TKey, string> | columnName | The column name function (mandatory) |
| Func<TValue, object> | itemValue | The item value function (mandatory) |
| Func<TKey, Type> | columnType | The column type function, default is string |
| Func<TKey, object> | defaultValue | The default value function, default is none |
Type Parameters
| Name | Description |
|---|---|
| TKey | |
| TValue |
Remarks
Use the function return value null, to suppress further item operations Transpose dynamic object: row.TransposeFrom((IDictionary<string, object>)dynamicObject);