CSLA .NET 10.0.0
A home for your business logic
Loading...
Searching...
No Matches
Csla.Data.SafeDataReader Class Reference

This is an IDataReader that 'fixes' any null values before they are returned to our business code. More...

Inheritance diagram for Csla.Data.SafeDataReader:

Public Member Functions

 SafeDataReader (IDataReader dataReader)
 Initializes the SafeDataReader object to use data from the provided DataReader object.
string GetString (string name)
 Gets a string value from the datareader.
virtual string GetString (int i)
 Gets a string value from the datareader.
object? GetValue (string name)
 Gets a value of type System.Object from the datareader.
virtual ? object GetValue (int i)
 Gets a value of type System.Object from the datareader.
int GetInt32 (string name)
 Gets an integer from the datareader.
virtual int GetInt32 (int i)
 Gets an integer from the datareader.
double GetDouble (string name)
 Gets a double from the datareader.
virtual double GetDouble (int i)
 Gets a double from the datareader.
SmartDate GetSmartDate (string name)
 Gets a SmartDate from the datareader.
virtual SmartDate GetSmartDate (int i)
 Gets a SmartDate from the datareader.
SmartDate GetSmartDate (string name, bool minIsEmpty)
 Gets a SmartDate from the datareader.
virtual SmartDate GetSmartDate (int i, bool minIsEmpty)
 Gets a SmartDate from the datareader.
Guid GetGuid (string name)
 Gets a Guid value from the datareader.
virtual Guid GetGuid (int i)
 Gets a Guid value from the datareader.
bool Read ()
 Reads the next row of data from the datareader.
bool NextResult ()
 Moves to the next result set in the datareader.
void Close ()
 Closes the datareader.
bool GetBoolean (string name)
 Gets a boolean value from the datareader.
virtual bool GetBoolean (int i)
 Gets a boolean value from the datareader.
byte GetByte (string name)
 Gets a byte value from the datareader.
virtual byte GetByte (int i)
 Gets a byte value from the datareader.
Int64 GetBytes (string name, Int64 fieldOffset, byte[] buffer, int bufferOffset, int length)
 Invokes the GetBytes method of the underlying datareader.
virtual Int64 GetBytes (int i, Int64 fieldOffset, byte[]? buffer, int bufferOffset, int length)
 Invokes the GetBytes method of the underlying datareader.
char GetChar (string name)
 Gets a char value from the datareader.
virtual char GetChar (int i)
 Gets a char value from the datareader.
Int64 GetChars (string name, Int64 fieldOffset, char[] buffer, int bufferOffset, int length)
 Invokes the GetChars method of the underlying datareader.
virtual Int64 GetChars (int i, Int64 fieldOffset, char[]? buffer, int bufferOffset, int length)
 Invokes the GetChars method of the underlying datareader.
IDataReader GetData (string name)
 Invokes the GetData method of the underlying datareader.
virtual IDataReader GetData (int i)
 Invokes the GetData method of the underlying datareader.
string GetDataTypeName (string name)
 Invokes the GetDataTypeName method of the underlying datareader.
virtual string GetDataTypeName (int i)
 Invokes the GetDataTypeName method of the underlying datareader.
virtual DateTime GetDateTime (string name)
 Gets a date value from the datareader.
virtual DateTime GetDateTime (int i)
 Gets a date value from the datareader.
virtual DateTimeOffset GetDateTimeOffset (string name)
 Gets an UTC date value from the datareader.
virtual DateTimeOffset GetDateTimeOffset (int i)
 Gets an UTC date value from the datareader.
decimal GetDecimal (string name)
 Gets a decimal value from the datareader.
virtual decimal GetDecimal (int i)
 Gets a decimal value from the datareader.
Type GetFieldType (string name)
 Invokes the GetFieldType method of the underlying datareader.
virtual Type GetFieldType (int i)
 Invokes the GetFieldType method of the underlying datareader.
float GetFloat (string name)
 Gets a Single value from the datareader.
virtual float GetFloat (int i)
 Gets a Single value from the datareader.
short GetInt16 (string name)
 Gets a Short value from the datareader.
virtual short GetInt16 (int i)
 Gets a Short value from the datareader.
Int64 GetInt64 (string name)
 Gets a Long value from the datareader.
virtual Int64 GetInt64 (int i)
 Gets a Long value from the datareader.
virtual string GetName (int i)
 Invokes the GetName method of the underlying datareader.
int GetOrdinal (string name)
 Gets an ordinal value from the datareader.
DataTable? GetSchemaTable ()
 Invokes the GetSchemaTable method of the underlying datareader.
int GetValues (object[] values)
 Invokes the GetValues method of the underlying datareader.
virtual bool IsDBNull (int i)
 Invokes the IsDBNull method of the underlying datareader.
virtual bool IsDBNull (string name)
 Invokes the IsDBNull method of the underlying datareader.
void Dispose ()
 Disposes the object.

Protected Member Functions

virtual void Dispose (bool disposing)
 Disposes the object.

Properties

IDataReader DataReader [get]
 Get a reference to the underlying data reader object that actually contains the data from the data source.
int Depth [get]
 Returns the depth property value from the datareader.
int FieldCount [get]
 Returns the FieldCount property from the datareader.
bool IsClosed [get]
 Returns the IsClosed property value from the datareader.
object? this[string name] [get]
 Returns a value from the datareader.
virtual ? object this[int i] [get]
 Returns a value from the datareader.
int RecordsAffected [get]
 Returns the RecordsAffected property value from the underlying datareader.

Detailed Description

This is an IDataReader that 'fixes' any null values before they are returned to our business code.

Constructor & Destructor Documentation

◆ SafeDataReader()

Csla.Data.SafeDataReader.SafeDataReader ( IDataReader dataReader)
inline

Initializes the SafeDataReader object to use data from the provided DataReader object.

Parameters
dataReaderThe source DataReader object containing the data.
Exceptions
ArgumentNullExceptiondataReader is null.

Member Function Documentation

◆ Close()

void Csla.Data.SafeDataReader.Close ( )
inline

Closes the datareader.

◆ Dispose() [1/2]

void Csla.Data.SafeDataReader.Dispose ( )
inline

Disposes the object.

◆ Dispose() [2/2]

virtual void Csla.Data.SafeDataReader.Dispose ( bool disposing)
inlineprotectedvirtual

Disposes the object.

Parameters
disposingTrue if called by the public Dispose method.

◆ GetBoolean() [1/2]

virtual bool Csla.Data.SafeDataReader.GetBoolean ( int i)
inlinevirtual

Gets a boolean value from the datareader.

Returns false for null.

Parameters
iOrdinal column position of the value.

◆ GetBoolean() [2/2]

bool Csla.Data.SafeDataReader.GetBoolean ( string name)
inline

Gets a boolean value from the datareader.

Returns false for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetByte() [1/2]

virtual byte Csla.Data.SafeDataReader.GetByte ( int i)
inlinevirtual

Gets a byte value from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetByte() [2/2]

byte Csla.Data.SafeDataReader.GetByte ( string name)
inline

Gets a byte value from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetBytes() [1/2]

virtual Int64 Csla.Data.SafeDataReader.GetBytes ( int i,
Int64 fieldOffset,
byte?[] buffer,
int bufferOffset,
int length )
inlinevirtual

Invokes the GetBytes method of the underlying datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.
bufferArray containing the data.
bufferOffsetOffset position within the buffer.
fieldOffsetOffset position within the field.
lengthLength of data to read.

◆ GetBytes() [2/2]

Int64 Csla.Data.SafeDataReader.GetBytes ( string name,
Int64 fieldOffset,
byte[] buffer,
int bufferOffset,
int length )
inline

Invokes the GetBytes method of the underlying datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
bufferArray containing the data.
bufferOffsetOffset position within the buffer.
fieldOffsetOffset position within the field.
lengthLength of data to read.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetChar() [1/2]

virtual char Csla.Data.SafeDataReader.GetChar ( int i)
inlinevirtual

Gets a char value from the datareader.

Returns Char.MinValue for null.

Parameters
iOrdinal column position of the value.

◆ GetChar() [2/2]

char Csla.Data.SafeDataReader.GetChar ( string name)
inline

Gets a char value from the datareader.

Returns Char.MinValue for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetChars() [1/2]

virtual Int64 Csla.Data.SafeDataReader.GetChars ( int i,
Int64 fieldOffset,
char?[] buffer,
int bufferOffset,
int length )
inlinevirtual

Invokes the GetChars method of the underlying datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.
bufferArray containing the data.
bufferOffsetOffset position within the buffer.
fieldOffsetOffset position within the field.
lengthLength of data to read.

◆ GetChars() [2/2]

Int64 Csla.Data.SafeDataReader.GetChars ( string name,
Int64 fieldOffset,
char[] buffer,
int bufferOffset,
int length )
inline

Invokes the GetChars method of the underlying datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
bufferArray containing the data.
bufferOffsetOffset position within the buffer.
fieldOffsetOffset position within the field.
lengthLength of data to read.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetData() [1/2]

virtual IDataReader Csla.Data.SafeDataReader.GetData ( int i)
inlinevirtual

Invokes the GetData method of the underlying datareader.

Parameters
iOrdinal column position of the value.

◆ GetData() [2/2]

IDataReader Csla.Data.SafeDataReader.GetData ( string name)
inline

Invokes the GetData method of the underlying datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetDataTypeName() [1/2]

virtual string Csla.Data.SafeDataReader.GetDataTypeName ( int i)
inlinevirtual

Invokes the GetDataTypeName method of the underlying datareader.

Parameters
iOrdinal column position of the value.

◆ GetDataTypeName() [2/2]

string Csla.Data.SafeDataReader.GetDataTypeName ( string name)
inline

Invokes the GetDataTypeName method of the underlying datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetDateTime() [1/2]

virtual DateTime Csla.Data.SafeDataReader.GetDateTime ( int i)
inlinevirtual

Gets a date value from the datareader.

Returns DateTime.MinValue for null.

Parameters
iOrdinal column position of the value.

◆ GetDateTime() [2/2]

virtual DateTime Csla.Data.SafeDataReader.GetDateTime ( string name)
inlinevirtual

Gets a date value from the datareader.

Returns DateTime.MinValue for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetDateTimeOffset() [1/2]

virtual DateTimeOffset Csla.Data.SafeDataReader.GetDateTimeOffset ( int i)
inlinevirtual

Gets an UTC date value from the datareader.

Returns DateTimeOffset.MinValue for null.

Parameters
iOrdinal column position of the value.

◆ GetDateTimeOffset() [2/2]

virtual DateTimeOffset Csla.Data.SafeDataReader.GetDateTimeOffset ( string name)
inlinevirtual

Gets an UTC date value from the datareader.

Returns DateTimeOffset.MinValue for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetDecimal() [1/2]

virtual decimal Csla.Data.SafeDataReader.GetDecimal ( int i)
inlinevirtual

Gets a decimal value from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetDecimal() [2/2]

decimal Csla.Data.SafeDataReader.GetDecimal ( string name)
inline

Gets a decimal value from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetDouble() [1/2]

virtual double Csla.Data.SafeDataReader.GetDouble ( int i)
inlinevirtual

Gets a double from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetDouble() [2/2]

double Csla.Data.SafeDataReader.GetDouble ( string name)
inline

Gets a double from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetFieldType() [1/2]

virtual Type Csla.Data.SafeDataReader.GetFieldType ( int i)
inlinevirtual

Invokes the GetFieldType method of the underlying datareader.

Parameters
iOrdinal column position of the value.

◆ GetFieldType() [2/2]

Type Csla.Data.SafeDataReader.GetFieldType ( string name)
inline

Invokes the GetFieldType method of the underlying datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetFloat() [1/2]

virtual float Csla.Data.SafeDataReader.GetFloat ( int i)
inlinevirtual

Gets a Single value from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetFloat() [2/2]

float Csla.Data.SafeDataReader.GetFloat ( string name)
inline

Gets a Single value from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetGuid() [1/2]

virtual Guid Csla.Data.SafeDataReader.GetGuid ( int i)
inlinevirtual

Gets a Guid value from the datareader.

Returns Guid.Empty for null.

Parameters
iOrdinal column position of the value.

◆ GetGuid() [2/2]

Guid Csla.Data.SafeDataReader.GetGuid ( string name)
inline

Gets a Guid value from the datareader.

Returns Guid.Empty for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetInt16() [1/2]

virtual short Csla.Data.SafeDataReader.GetInt16 ( int i)
inlinevirtual

Gets a Short value from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetInt16() [2/2]

short Csla.Data.SafeDataReader.GetInt16 ( string name)
inline

Gets a Short value from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetInt32() [1/2]

virtual int Csla.Data.SafeDataReader.GetInt32 ( int i)
inlinevirtual

Gets an integer from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetInt32() [2/2]

int Csla.Data.SafeDataReader.GetInt32 ( string name)
inline

Gets an integer from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetInt64() [1/2]

virtual Int64 Csla.Data.SafeDataReader.GetInt64 ( int i)
inlinevirtual

Gets a Long value from the datareader.

Returns 0 for null.

Parameters
iOrdinal column position of the value.

◆ GetInt64() [2/2]

Int64 Csla.Data.SafeDataReader.GetInt64 ( string name)
inline

Gets a Long value from the datareader.

Returns 0 for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetName()

virtual string Csla.Data.SafeDataReader.GetName ( int i)
inlinevirtual

Invokes the GetName method of the underlying datareader.

Parameters
iOrdinal column position of the value.

◆ GetOrdinal()

int Csla.Data.SafeDataReader.GetOrdinal ( string name)
inline

Gets an ordinal value from the datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetSchemaTable()

DataTable? Csla.Data.SafeDataReader.GetSchemaTable ( )
inline

Invokes the GetSchemaTable method of the underlying datareader.

◆ GetSmartDate() [1/4]

virtual SmartDate Csla.Data.SafeDataReader.GetSmartDate ( int i)
inlinevirtual

Gets a SmartDate from the datareader.

A null is converted into the min possible date See Chapter 5 for more details on the SmartDate class.

Parameters
iOrdinal column position of the value.

◆ GetSmartDate() [2/4]

virtual SmartDate Csla.Data.SafeDataReader.GetSmartDate ( int i,
bool minIsEmpty )
inlinevirtual

Gets a SmartDate from the datareader.

Parameters
iOrdinal column position of the value.
minIsEmptyA flag indicating whether the min or max value of a data means an empty date.

◆ GetSmartDate() [3/4]

SmartDate Csla.Data.SafeDataReader.GetSmartDate ( string name)
inline

Gets a SmartDate from the datareader.

A null is converted into min possible date See Chapter 5 for more details on the SmartDate class.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetSmartDate() [4/4]

SmartDate Csla.Data.SafeDataReader.GetSmartDate ( string name,
bool minIsEmpty )
inline

Gets a SmartDate from the datareader.

A null is converted into either the min or max possible date depending on the MinIsEmpty parameter. See Chapter 5 for more details on the SmartDate class.

Parameters
nameName of the column containing the value.
minIsEmptyA flag indicating whether the min or max value of a data means an empty date.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetString() [1/2]

virtual string Csla.Data.SafeDataReader.GetString ( int i)
inlinevirtual

Gets a string value from the datareader.

Returns empty string for null.

Parameters
iOrdinal column position of the value.

◆ GetString() [2/2]

string Csla.Data.SafeDataReader.GetString ( string name)
inline

Gets a string value from the datareader.

Returns empty string for null.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetValue() [1/2]

virtual ? object Csla.Data.SafeDataReader.GetValue ( int i)
inlinevirtual

Gets a value of type System.Object from the datareader.

Parameters
iOrdinal column position of the value.

◆ GetValue() [2/2]

object? Csla.Data.SafeDataReader.GetValue ( string name)
inline

Gets a value of type System.Object from the datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ GetValues()

int Csla.Data.SafeDataReader.GetValues ( object[] values)
inline

Invokes the GetValues method of the underlying datareader.

Parameters
valuesAn array of System.Object to copy the values into.

◆ IsDBNull() [1/2]

virtual bool Csla.Data.SafeDataReader.IsDBNull ( int i)
inlinevirtual

Invokes the IsDBNull method of the underlying datareader.

Parameters
iOrdinal column position of the value.

◆ IsDBNull() [2/2]

virtual bool Csla.Data.SafeDataReader.IsDBNull ( string name)
inlinevirtual

Invokes the IsDBNull method of the underlying datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

◆ NextResult()

bool Csla.Data.SafeDataReader.NextResult ( )
inline

Moves to the next result set in the datareader.

◆ Read()

bool Csla.Data.SafeDataReader.Read ( )
inline

Reads the next row of data from the datareader.

Property Documentation

◆ DataReader

IDataReader Csla.Data.SafeDataReader.DataReader
getprotected

Get a reference to the underlying data reader object that actually contains the data from the data source.

◆ Depth

int Csla.Data.SafeDataReader.Depth
get

Returns the depth property value from the datareader.

◆ FieldCount

int Csla.Data.SafeDataReader.FieldCount
get

Returns the FieldCount property from the datareader.

◆ IsClosed

bool Csla.Data.SafeDataReader.IsClosed
get

Returns the IsClosed property value from the datareader.

◆ RecordsAffected

int Csla.Data.SafeDataReader.RecordsAffected
get

Returns the RecordsAffected property value from the underlying datareader.

◆ this[int i]

virtual ? object Csla.Data.SafeDataReader.this[int i]
get

Returns a value from the datareader.

Parameters
iOrdinal column position of the value.

◆ this[string name]

object? Csla.Data.SafeDataReader.this[string name]
get

Returns a value from the datareader.

Parameters
nameName of the column containing the value.
Exceptions
ArgumentExceptionname is null, string.Empty or only consists of white spaces.

The documentation for this class was generated from the following file: