PetaPoco – a sorta orm

Recently, I got a little frustrated with Entity Framework and linq. The performance feels slow and the voodoo sql it generates could be better.

For high usage web applications, EF is probably not the right tool.

You might have heard of dapper-dot-net – a simple object mapper from the guys at Stackoverflow.
Their page lists some performance figures and one of them caught my eye – PetaPoco.

I really love the simpleness of it.
Here’s an example from the PetaPoco page:

// Represents a record in the "articles" table
public class article
{
    public long article_id { get; set; }
    public string title { get; set; }
    public DateTime date_created { get; set; }
    public bool draft { get; set; }
    public string content { get; set; }
}
Next, create a PetaPoco.Database and run the query:

// Create a PetaPoco database object
var db=new PetaPoco.Database("connectionStringName");

// Show all articles    
foreach (var a in db.Query<article>("SELECT * FROM articles"))
{
    Console.WriteLine("{0} - {1}", a.article_id, a.title);
}

After playing around with it a bit, I’m really liking it. I’m going to start upgrading my personal project, Snowboard Finder, with it.
Luckily Snowboard Finder implements the Repository pattern so it should be cinch… right? 😛

Advertisements

3 thoughts on “PetaPoco – a sorta orm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s