IDataReader ExecuteReader()

This SqlCommand wrapper class illustrates returning the ListEx as a valid IDataReader. In this example
the GenericDataObject properties will be created using the SqlDataReader's field information. Note that at initialization
the readerResult object contains no records, this Fill() method must first be called to initiate the read process.

Using a dynamically created collection of classes could serve a purpose, instead use custom templates for your SqlCommand
if the type collection must be determined at compile time.

public IDataReader ExecuteReader(CommandBehavior behavior)
{
    //this is to demonstrate the honoring of the IDataReader interface
    if (this._innerCommand != null)
    {
        ListEx<GenericDataObject> readerResult =
            new ListEx<GenericDataObject>(this._innerCommand.ExecuteReader(behavior));
       
        return readerResult;
    }
    else return default(IDataReader);
}
public IDataReader ExecuteReader()
{
    //this is to demonstrate by honoring the IDataReader interface
    if (this._innerCommand != null)
    {
        ListEx<GenericDataObject> readerResult =
            new ListEx<GenericDataObject>(this._innerCommand.ExecuteReader());
        
        return readerResult;
    }
    else return default(IDataReader);
}

Last edited Dec 14, 2010 at 3:17 PM by Caprisoft, version 1

Comments

No comments yet.