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? 😛