% group # Abstract accessors %> <% order # 20 %>
The following example demonstrates how to create and use an abstract data accessor class. All abstract methods of the class are generated at run-time depending on each method declaration. Every part of the method declaration is important. Method's return value specifies one of the Execute methods in the following way:
Return Type | Execute Method |
---|---|
IDataReader interface | ExecuteReader |
Subclass of DataSet | ExecuteDataSet |
Subclass of DataTable | ExecuteDataTable |
Class implementing the IList interface | ExecuteList or ExecuteScalarList |
Class implementing the IDictionary interface | ExecuteDictionary or ExecuteScalarDictionary |
void | ExecuteNonQuery |
string, byte[] or value type | ExecuteScalar |
In any other case | ExecuteObject |