PetaPoco: Micro ORM For .NET

| by Roopesh Shenoy Follow 0 Followers on Jun 22, 2011. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

PetaPoco is a thin Object Relational Mapper (ORM) for .NET applications. Unlike full-fledged ORMs like NHibernate or Entity Framework, the emphasis is on simplicity of use and performance rather than richness of features. PetaPoco comes in a single C# file, works with strongly typed POCOs, supports class generation with T4 templates and more.

PetaPoco’s most interesting features are

  • Works with SQL Server, SQL Server CE, MySQL, PostgreSQL and Oracle databases
  • Helper methods for Insert/Delete/Update/Save and IsNew
  • Easy Transaction Support
  • Paged requests automatically work out total record count and fetch a specific page
  • Parameter replacement Support, can grab named parameters from object properties
  • Includes a low friction SQL Builder class
  • Partial Record Updates
  • Includes T4 Templates to generate POCO classes from database schema

All these features are explained in more detail along with samples in the PetaPoco website.

In terms of performance, PetaPoco is right up there with Dapper, only minimally slower than hand-coded DAL.

There are several tutorials that can help get started – series of blog posts on the official website as well as some independent posts. Besides, since it is open source, it is much easier to add conditions to handle specific scenarios like spatial data

Micro ORMs have started becoming popular, with many open source projects being released recently. Some of the other well known ones for .NET are Dapper and Massive. These are simpler and more efficient than full-fledged ORMs, often expecting the SQL statement to be hand-written rather than being generated completely dynamically. They also do not need verbose mapping files, that could become tedious to maintain and debug.  

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

No xml mapping files by Binoj Antony

Would have been nice if PetaPoco also supported Xml mapping files(, I hate to specify the attributes in DTO or for that matter in any form of compiled code. Low coupling anyone..

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you