MattC,
You can just overload the method to accept a data row or an IDataRecord
(you might also want to consider a DataRowView, because you might be working
with those as well).
What I think you want to do is actually create a method that takes the
actual value you want to work with, and then have overloads which will
extract the value from the three data structures. There isn't a common
interface/base class that they all share that exposes the indexer, so you
will have to write that logic yourself.
You ^could^ use reflection to get the indexer and then get the value,
but to be quite honest, it really isn't worth the hassle.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"MattC" <m@m.comwrote in message
news:O8***************@TK2MSFTNGP06.phx.gbl...
Hi,
Given that a data item in both a DataRow and DataReaders IDataRecord can
be accessed using something like
dr["ColumnName"].
I'd like to create method that accepts either a DataRow or IDataRecord.
Anyone know if this is possible? Is there an interface that exposes an
indexer that I can cast them to?
TIA
MattC