Try our conversational search powered by Generative AI!

Class TypedDataRowExtensions

Inheritance
System.Object
TypedDataRowExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Mediachase.Commerce.Extensions
Assembly: Mediachase.Commerce.dll
Version: 13.30.0
Syntax
public static class TypedDataRowExtensions

Methods

Get<TRow, TValue>(TRow, Expression<Func<TRow, TValue>>)

Gets the property value defined in property from the instance row.

Declaration
public static TValue Get<TRow, TValue>(this TRow row, Expression<Func<TRow, TValue>> property)
    where TRow : DataRow
Parameters
Type Name Description
TRow row

The instance to read the property from.

System.Linq.Expressions.Expression<System.Func<TRow, TValue>> property

An System.Linq.Expressions.Expression defining the property to read, e.g. 'x => x.MyProp' to read the property 'MyProp' from row.

Returns
Type Description
TValue

The property value, with fallback to the default of TValue if the Is[PropertyName]Null() method of TRow exists and returns true.

Type Parameters
Name Description
TRow

The typed System.Data.DataRow.

TValue

The property value type.

Set<TRow, TValue>(TRow, Expression<Func<TRow, TValue>>, TValue)

Sets the property value defined in property on the instance row if it doesn't already have the same value. This avoids marking the data row as modified if the value hasn't changed.

Declaration
public static TRow Set<TRow, TValue>(this TRow row, Expression<Func<TRow, TValue>> property, TValue value)
    where TRow : DataRow
Parameters
Type Name Description
TRow row

The instance to set the property on.

System.Linq.Expressions.Expression<System.Func<TRow, TValue>> property

An System.Linq.Expressions.Expression defining the property to set, e.g. 'x => x.MyProp' to set the property 'MyProp' from row.

TValue value

The property value to set. If the System.Data.DataRow.RowState of row is System.Data.DataRowState.Unchanged and value is the same as the current value, no action is performed. This is to avoid marking the row as modified when not necessary. If value is null, the Set[PropertyName]Null() method of TRow will be used to null out the column. If such a method does not exist, the property will be set set to null.

Returns
Type Description
TRow
Type Parameters
Name Description
TRow

The typed System.Data.DataRow.

TValue

The property value type.

Set<TRow, TValue>(TRow, Expression<Func<TRow, TValue>>, Nullable<TValue>)

Sets the property value defined in property on the instance row if it doesn't already have the same value. This avoids marking the data row as modified if the value hasn't changed.

Declaration
public static TRow Set<TRow, TValue>(this TRow row, Expression<Func<TRow, TValue>> property, TValue? value)
    where TRow : DataRow where TValue : struct
Parameters
Type Name Description
TRow row

The instance to set the property on.

System.Linq.Expressions.Expression<System.Func<TRow, TValue>> property

An System.Linq.Expressions.Expression defining the property to set, e.g. 'x => x.MyProp' to set the property 'MyProp' from row.

System.Nullable<TValue> value

The property value to set. If the System.Data.DataRow.RowState of row is System.Data.DataRowState.Unchanged and value is the same as the current value, no action is performed. This is to avoid marking the row as modified when not necessary. If value is null and the underlying data column is nullable, the column will be set to null (by calling the Set[PropertyName]Null() method). If value is null, the Set[PropertyName]Null() method of TRow will be used to null out the column. If such a method does not exist, the property will be set to the default of TValue.

Returns
Type Description
TRow
Type Parameters
Name Description
TRow

The typed System.Data.DataRow.

TValue

The property value type.

TryGet<TRow, TValue>(TRow, Expression<Func<TRow, TValue>>, out Boolean)

Gets the property value defined in property from the instance row.

Declaration
public static TValue TryGet<TRow, TValue>(this TRow row, Expression<Func<TRow, TValue>> property, out bool isNull)
    where TRow : DataRow
Parameters
Type Name Description
TRow row

The instance to read the property from.

System.Linq.Expressions.Expression<System.Func<TRow, TValue>> property

An System.Linq.Expressions.Expression defining the property to read, e.g. x => x.MyProp to read the property 'MyProp' from row.

System.Boolean isNull

Output parameter which will be set to true if the Is[PropertyName]Null() method of TRow exists and returns true.

Returns
Type Description
TValue

The property value, with fallback to the default of TValue if isNull has been set to true.

Type Parameters
Name Description
TRow

The typed System.Data.DataRow.

TValue

The property value type.