Do you have the solution?
Given that System.Data.IDataRecord and System.Data.DataRow both share the following accessors:
IDataRecord Interface
object this[ string name ] { get; }
object this[ int i ] { get; }
DataRow public object this[ int columnIndex ] { get; set; }
public object this[ string columnName ] { get; set; }
When I'm building my DAL objects, I invariably have to build two constructors for my objects--one which takes the IDataRecord interface, and another which takes the DataRow object. The constructors are usually identical except for the type of the argument being passed to it. If a common interface could be extracted and shared between the DataReader and DataRow I'd only have to use one constructor.
I can see that the primary problem facing interface extraction is the fact that the DataReader is readonly, and the DataRow is read/write. The only way I see around this problem is if the compiler treated a read/write property as satisfying the Readonly condition of the interface. Or maybe we need a new scope term for Interfaces, such as "CanRead" and "CanWrite". A standard read/write property and a readonly property would satisfy the CanRead scope modifier. Likewise for the CanWrite portion. In other words, the Interface that whatever access level is given to the property, it must be Read-able, or Write-able, or both even.
Has anyone found a way around my core problem? What do you think the best way to solve it in future versions of the framework would be?