Class DataRecordContainer
Adapts the System.Data.IDataRecord interface to IDataContainer.
public class DataRecordContainer : IDataContainer, ISimpleDataContainer, IExternalDataContainerMetadata
- Inheritance
-
objectDataRecordContainer
- Implements
- Extension Methods
Constructors
DataRecordContainer(IDataRecord)
Initializes a new instance of the DataRecordContainer class using the dataRecord provided.
public DataRecordContainer(IDataRecord dataRecord)
Parameters
dataRecordIDataRecordData record to initialize the container with.
Exceptions
- ArgumentNullException
Thrown when
dataRecordis null.- InvalidOperationException
Thrown when
dataRecordcontains duplicate column names.
Properties
ColumnNames
Gets a list of all column names.
public List<string> ColumnNames { get; }
Property Value
- List<string>
IsFromCmsDatabase
Returns true if the given data does not contain any external data (data not from CMS database).
public bool IsFromCmsDatabase { get; set; }
Property Value
- bool
this[string]
Gets or sets the value of a column identified by its name.
public object this[string columnName] { get; set; }
Parameters
columnNamestringName of column whose value to get or set.
Property Value
- object
Returns the value of the column.
Remarks
The DataRecordContainer does not support setting of column values. Calling this property setter always throws System.NotSupportedException.
Methods
ContainsColumn(string)
Gets a value indicating whether the record container contains the specified column.
public bool ContainsColumn(string columnName)
Parameters
columnNamestringName of column whose presence to test.
Returns
- bool
Returns true if
columnNameis contained in the record container, otherwise returns false.
GetValue(string)
Gets the value of a column identified by its name, if the column exists within this record container.
public object GetValue(string columnName)
Parameters
columnNamestringName of column whose value to get.
Returns
- object
Returns the value of the column, if the column exists. Otherwise returns null.
SetValue(string, object)
Sets the value of a column identified by its name, if the column exists within this record container.
public bool SetValue(string columnName, object value)
Parameters
columnNamestringName of column whose value to set.
valueobjectThe value to be set.
Returns
- bool
Returns true if the
columnNamewas set, returns false ifcolumnNamedoes not exist within the record container.
Remarks
The DataRecordContainer does not support setting of column values. Calling this method always throws System.NotSupportedException.
TryGetValue(string, out object)
Tries to retrieve the value of a column identified by its name. The returned value indicates whether the columnName exists within this record container.
public bool TryGetValue(string columnName, out object value)
Parameters
columnNamestringName of column whose value to get.
valueobjectThe value of the column, if the column exists. Otherwise null.
Returns
- bool
Returns true if
columnNameis contained in the record container, otherwise returns false.