Friday, 18 March 2011
Today I put up an first pass at a simple .NET data access layer called PetaPoco - "a tiny ORM-ish thing for your POCOs".
This post is about PetaPoco - "a tiny ORMish thing for your POCOs". Read more on the PetaPoco Project Page.
Last week I stumbled upon Rob Conery's Massive project which provides a really light-weight data access layer leveraging .NET 4's dynamic object support. So I played with it for a bit, and it's great but I really needed something that would run under Mono 2.6 (ie: no dynamic support) and I really did miss having properly typed objects.
Up until now I've been using Subsonic for data-access but I'm starting to lean away from LINQ - so it's becoming overkill for my purposes. I wanted something a bit like Subsonic but with all the simplicity of Massive. Rob's claim of Massive being only 400 lines of code intrigued me and I wondered if something similar could be done without dynamics using just POCO objects.
Turns out it can.
One late night and half a day of coding and I've got support for queries, insert/update/delete operations, transaction support and support for a really simple SQL builder. The line count at time of writing this: 800 lines. Not bad.
I wont repeat all the details here because there's a walk through on the PetaPoco project page. I've also updated a simple website I'm working on to use it and it all went amazingly well... though I have some ideas for a few improvements. Stay tuned.
Leave a comment