This project is read-only.
Please Note: This CodePlex site is used for all project tracking, but the source code is hosted at

Project Description

An ActiveRecord implementation for the .NET framework using ADO.NET.

Brief Overview

The purpose of this project is to implement the Active Record pattern using ADO.NET. An Active Record is an "object that wraps a row in a database table or view; encapsulates the database access, and adds domain logic on that data" (1).

This pattern is useful when the class domain model matches the database schema. Each table in the database is represented by a class. Database columns are represented as fields in the class.

At it's core an Active Record object supports the following operations:
  1. Constructing an Active Record instance from a database row
  2. Constructing a new instance via a constructor or a "create" method
  3. Static Fetch methods for retrieving data (including support for conditions)
  4. A "Save" method that either inserts or updates information in the database
  5. Exposes database columns as property fields that can be modified
  6. Custom business logic

Again, this pattern is applicable only when the application's domain can be matched to the database schema. In other cases, a Domain Mapper is usually more appropriate. Refer to Martin Fowler's "Patterns of Enterprise Architecture" for additional information.

Why This Implementation?

Currently, the most popular Active Record implementation that I am aware of is the Castle ActiveRecord Project (2). This project uses NHibernate (3) for data access. Although the implementation is quite mature, I had several issues with it.
  1. The implementation requires several dependencies (NHibernate, log4net, Windsor). I wanted something with a smaller footprint.
  2. Although it abstracts a lot of NHibernate away, you still need to be familiar with it, especially with configuration. NHibernate is extremely useful for Domain Mappers, but to me it seemed like overkill for Active Record.
  3. I wanted something that I could use pure ADO.NET with for small projects, where the overhead of the other layers is not needed. In addition, I wanted something that would still allow layer separation instead of using SqlDataSources and be "lighter" than DataSets.


I'm envisioning this project in 3 releases:
  1. Core -- Implementation of the core Active Record pattern (i.e. CRUD operations)
  2. Validation Support -- Data validators for length, null, regex, etc.
  3. Code Generation -- Generating basic ActiveRecord classes from a database schema. Business logic can be added to these generated classes.
  4. Code Templates / Snippets -- Various VS template and code snippet helpers

Right now I'm concentrating on Release #1. Then most likely #2. I haven't decided if/when #3 & #4 will happen.

(1) - Fowler, Martin: Patterns of Enterprise Architecture
(2) - Castle ActiveRecord
(3) - NHibernate Project

Last edited Feb 11, 2008 at 4:23 AM by TheThirdSwitch, version 4