Problem Solved
Last week I blogged about a problem I was having finding common ground between the DataReader object, and the Datarow object. I complained of having to write two different constructors that were identical in nature except for the type of object received. Why the solution didn't occur to me before now I can't say, but the answer is the GoF Adapter pattern.
I just wrote an object that adapts the DataRow to the IDataRecord Interface. Problem solved. Simple.
There were some methods that I couldn't completely implement, such as the one that referenced the parent IDataReader object (there isn't one in this scenario), but it should work find for my purposes.
<source>
Public Class DataRowAdapter
Implements System.Data.IDataRecord
Private _row As DataRow
Protected ReadOnly Property Row() As DataRow
Get
Return Me._row
End Get
End Property #
Region "IDataRecord" ... snipped
Default Public Overloads ReadOnly Property Item(ByVal i As Integer) As Object Implements System.Data.IDataRecord.Item
Get
Return Row(i) End Get End Property Default Public Overloads ReadOnly Property Item(ByVal name As String) As Object Implements System.Data.IDataRecord.Item
Get
Return Row(name) End Get End Property #
End Region Public Sub New(ByVal row As DataRow)
Me._row = row End Sub End
Class </source>