Friday, March 30, 2012

PetaPoco-A single file ORM for .Net

PetaPoco is an ORM for mapping your Database object.After seeing above statement the first question that will come to your mind is "there are quite few good ORM's like Entity Frameworks and it works very well for us. Why do we need another ORM ? What so special in that? " . OK let me change my sentence a bit. It is a single file solution with just 1500 lines of code. Hmm looks interesting ? no dlls ?? Yup there is no other dependency .Now it is bit interesting isn't it ? So the next question is what are the features of PetaPoco and is it really useful ? I have listed the features below. After reading that you can decide whether it is useful or not (I am sure you will find it useful ), you can read the complete petapoco documentation Here . It takes hardly 1 hr to read the complete article but it is really worth for that.

  • Works with strictly undecorated POCOs, or attributed almost-POCOs.
  • Helper methods for Insert/Delete/Update/Save and IsNew
  • Paged requests automatically work out total record count and fetch a specific page.
  • Easy transaction support.
  • Better parameter replacement support, including grabbing named parameters from object properties.
  • Great performance by eliminating Linq and fast property assignment with DynamicMethod generation.
  • Includes T4 templates to automatically generate POCO classes for you.
  • The query language is SQL... no weird fluent or Linq syntaxes (yes, matter of opinion)
  • Includes a low friction SQL builder class that makes writing inline SQL much easier.
  • Hooks for logging exceptions, installing value converters and mapping columns to properties without attributes.
  • Works with SQL Server, SQL Server CE, MySQL, PostgreSQL and Oracle.
  • Works under .NET 3.5 or Mono 2.6 and later.
  • Experimental support for dynamic under .NET 4.0 and Mono 2.8
  • NUnit unit tests.