Search a CodePlex project

Project Description
This Generic List implements the IDataReader interface and displays the usage of Linq, Lamba expressions and some creative thought around working with collection types. I hope it can serve as reference to your projects.

ListEx<T>() : IDataReader

For this project I've decided to implement a Generic List that inherits the IDataReader interface.
The List had to support IDataReader capabilities and should be able to construct a DataSet from its property base.
I wanted the List to also accept an IDataReader as a constructor argument, this would propose that the List would use
a TypeBuilder to dynamically build the Type according to the IDataReader schema.

To implement the IDataReader capability, I decided to add a ReadableProperty Attribute "custom" to the underlying class contained
within the List. The developer should mark properties that with the ReadableProperty attribute and can also set a property as a primary key
within that Type. Future extensions or additions will be decided on the interest of the project by the general public.

Additions may include generic object construction based on schema information received from the database or XML schema set.
These objects could be shared "in or out" of process rather easily due to flexible construct options.

Within this project you can expect to see:
  • IDataReader implementation
  • Reflection
  • Lambda Expressions
  • Linq
  • Generic List Wrapper
  • Data Access strategy "simple" displaying the use of a dynamic type property mapping
  • Dual List to DataSet conversion
  • Usage of Custom Attributes
  • Basic relational attribute to properties "Primary key"
  • Sample Code describing some thought to possibile usage

Sample Code

Please add your reviews and comments
Sample: ListEx<T>(IDataReader reader, Type typeToMap)
There are several constructors available on ListEx, the example code illustrates the construct of
mapping a IDataReader object to your Type to map object. Note that the last example uses the
contactList object as argument to construct a new ContactPerson List.

Sample: ListEx<T>(IDataReader reader)
This example takes only the IDataReader object and returns a dynamically created class of type GenericDataObject.
Properties are added to the Type by using the IDataReader.GetName(int x) & IDataReader.GetDataType(int x) methods.
As seen previously you can cast or map this collection to a known type also.

Sample Application Simulator Screenshot
Nothing pretty, but usable through adding breakpoints and stepping through the code to familiarize yourself.
Use what you can, and please add your thoughts and reviews.


Zack Evans

Application's Architect, South Africa

Not affiliated with Microsoft and CodePlex
To remove your project or any question, please contact us: [email protected]