About 10 minutes before receiving your email, I figured out how to work with the IDataReader implementation mentioned in the link in the original question. I think I actually prefer his implementation of the GetColumnDelegate to retrieve the columns instead of pssing them in as it feels a little more generic-ized. Also, his is geared more towards collections.
Your example though is very easy to understand though and I appreciate you sharing it with me. I might tinker around with it especially regarding your suggestion to get it away from the arrays and supporting a generic collection. Thanks.
Main Topics
Browse All Topics





by: MogalManicPosted on 2009-10-23 at 06:35:39ID: 25644241
I have written a MockDataReader for use in unit testing. It is constructed like this:
object[][] PersionList=new object[] {
new object[] {"Tom", "Jones"}
IDataReader MockReader=new MockDataReader({"First Name", "Last Name"}, PersonList);
So you see, all of the "smarts" is precomputed in the constructor. You could do something similar but instead of using an array of arrays, you could use IEnumerable<Person> and then use reflection to determine the column list and possibly the datatypes.
Select allOpen in new window