BT

InfoQ Homepage News PetaPoco: Micro ORM For .NET

PetaPoco: Micro ORM For .NET

Bookmarks

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
Style

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.

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

Community comments

  • No xml mapping files

    by Binoj Antony /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Would have been nice if PetaPoco also supported Xml mapping files(xmldatamapper.codeplex.com/), 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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.