views:

286

answers:

3

Could someone possibly provide code to a very simple activerecord class that I could use to learn with? Looking at the source on projects like Castle and SubSonic is a bit overwhelming. I'd like to learn the active record pattern to get an idea of how it works. I know whatever I build would be nothing compared to Castle or SubSonic, but I think the learning experience would be great.

I looked at Hayden ActiveRecord, but I can't seem to find the source. Most of the active record related postings on his site are quite old.

Thanks.

+2  A: 

Wikipedia provides some simple pseudocode that demonstrates the concept, beyond that I'd suggest trying to implement it and then coming back if you have any difficulties.

My experience taught me that I never learned anything so well as when I struggled with it myself in the first instance, asking for help when you've started is fine, but you need to get some code down to prove to yourself that you really understand the space otherwise you just end up cutting and pasting.

Lazarus
Thanks Martin, good catch!
Lazarus
+1  A: 

Take a look at Castle Active record.

Beatles1692
A: 

Subsonic 3 can implement the ActiveRecord pattern. http://www.subsonicproject.com/

You can study the templates and the output they generate.

Development 4.0