With the help of you guys, I have created an object that is similiar to the recordset in classic asp.
public class RecordSet: List<Dictionary<string, object>>
{
}
So I can access the data like:
RecordSet rs = new RecordSet();
rs[rowID]["columnName"];
How can I get access like this also, i.e. ordinal referece:
rs[rowId][2];
Please don't ask me why I just don't use a datatable, this is partly for fun and learning and testing hehe
From stackoverflow
-
Also you want to look at the IEnumerable interface, which you can implement to be able to 'foreach' loop through the class's rows.
-
Something that would work more like a RecordSet could look like this:
public class RecordSet { private Dictionary<string, int> _nameLookup; private List<List<object>> _rows; private int _currentRow; ... public object this[int index] { return _rows[_currentRow][index]; } public object this[string name] { return this[_nameLookup[name]]; } ... }
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.