Mr. Mario Meštrović showcases some pros and cons of choosing a Micro ORM framework over traditionally well known Entity Framework. Stack Overflow uses Dapper. Lets see why.
2. Micro ORM
Currently the most prominent micro ORMs that are available for use in
.NET are:
Massive by Rob Connery
Simple.Data by Mark Rendle
PetaPoco by Top Ten Software
FluentData -Micro ORM with a fluent API that makes it simple to query a
database
Dapper by Sam Saffron
3. Massive
Massive started life as Rob Connery playing around with the new Dynamic
datatype introduced in .NET 4.0. He explains his reasoning as:
"I wanted to stay as close to the "metal" as I possibly could. This (to me) meant
that I didn't want to worry about Types, Tracking Containers, Contexts and so on.
What I did want to do is describe my table - and this is the only type I have
(which, ironically, is a Dynamic type)".
So it just returns Dynamic objects
Doesn’t support POCO-s
4. Simple.Data
Mark Rendle's Simple.Data is, in some ways, one of the grand-fathers of the new wave of
pared-down data access libraries (it inspired Massive, for example). Is it an ORM? Well, Mark
would say not. He states on his blog:
It's a database access library built on the foundations of the dynamic keyword and
components in .NET 4.0.
It's not an O/RM. It looks a bit like one, but it doesn't need objects, it doesn't need a
relational database, and it doesn't need any mapping configuration. So it's an O/RM without
the O or the R or the M. So it's just a /.
Like Massive works with Dynamic objects
Doesn’t support POCO-s
5. Example
Simple.Data
var db = Database.Open(); // Connection specified in config.
var user = db.Users.FindByNameAndPassword(name, password);
Massive
dynamic table = new Products(); //"dynamic" is important here -
don't use "var"!
var productsFour = table.Find(CategoryID:4,columns:"ProductName");
Seems immature!?
6. Dapper
THE POINT:
I've recently started using their micro-ORM Dapper, and I
like it a lot. I get the performance of hand-coded SQL,
but without the tedious mapping from SqlDataReader to
my entity.
7. Dapper
Why so fast?
it’s fast because it uses dynamic method generation (MSIL) to
assign column values to properties
ExpandoObjects
Supports POCOs
Doesn’t support sql querying, but it has it’s neat ways of mapping hand
crafted SQL queries to your POCOs
8. PetaPoco
PetaPoco is a tiny, fast, single-file micro-ORM for .NET and Mono.
Like Massive it’s a single file that you easily add to any project
Unlike Massive it works with strongly typed POCO‘s
Like Massive, it now also supports dynamic Expandos too – read more
Like ActiveRecord, it supports a close relationship between object and database
table
Like SubSonic, it supports generation of poco classes with T4 templates
Like Dapper, it’s fast because it uses dynamic method generation (MSIL) to assign
column values to properties
9. FluentData (newest)
FluentData is a Micro ORM that makes it simple to select, insert, update
and delete data in a database.
It gives the developer the power of ADO.NET but with the convenience of
an ORM. It has a simple to use fluent API that uses SQL - the best and
most suitable language to query data, and SQL or fluent builders to insert,
update and delete data.
Fluent API for querying – ftw!
12. Cons
LINQ (D-UH!),
well.. this one is the most expensive so that’s the point
object tracking,
transaction management,
intellisense,
compile-time query checking
etc.
13. Conclusion
There is no single silver bullet
=>Use both Dapper and EntityFramework