Scott Hanselman

Hanselminutes Podcast 262 - The Rise of the Micro-ORM with Sam Saffron and Rob Conery

April 21, '11 Comments [11] Posted in Data | Open Source | Podcast
Sponsored By

Scott's at Mix this week and he sits down with Sam Saffron and Rob Conery to talk about their Micro-ORMs. What have they done in less than 400 lines of code, that the rest of the planet needs a dozen assemblies for? Should you abandon your ORM and start writing inline SQL? All this and more.

Here's a few examples to look at while you listen to the show:

Dapper

var guid = Guid.NewGuid();
var dog = connection.ExecuteMapperQuery<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });

Massive

var tbl = new Products();
var products = tbl.All(where: "CategoryID = @0 AND UnitPrice > @1", orderBy: "ProductName", limit: 20, args: 5,20);

Download: MP3 Full Show

Links:

NOTE: If you want to download our complete archives as a feed - that's all 262 shows, subscribe to the Complete MP3 Feed here.

Also, please do take a moment and review the show on iTunes.

Subscribe: Subscribe to Hanselminutes or Subscribe to my Podcast in iTunes or Zune

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface and developer tools, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET AJAX,MVC,Silverlight, Windows Forms and WPF. Enjoy developer tools like .NET Reporting,ORM,Automated Testing Tools, Agile Project Management Tools, and Content Management Solution. And now you can increase your productivity with JustCode, Telerik’s new productivity tool for code analysis and refactoring. Visitwww.telerik.com.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Friday, April 22, 2011 7:25:26 PM UTC
No love for Simple.Data? https://github.com/markrendle/Simple.Data
Saturday, April 23, 2011 12:08:23 PM UTC
@NotMyself - I think you may be missing the "Micro-" part of Micro-ORM as Dapper is a single file at around 500 lines of code and Massive well... isn't, at less than 400 lines in a single .cs file. Good to know SimpleData is out there - I hadn't heard of it before and it seems interesting, but just browsing the source repo (https://github.com/markrendle/Simple.Data/tree/master/Simple.Data) it's definitely not a micro-orm.
Monday, May 02, 2011 5:58:57 AM UTC
Hey Scott,

I Like your show and the rise of the MicroORMs:).

It is a refreshing counterpath to the hyped "enterprise" way of doing data. A clever friend of mine has as reaction of and burst of nHibernate frustration developed MicroDAL. I recommend checking it out on CodePlex http://microdal.codeplex.com.

Code on!

/Per
Tuesday, May 10, 2011 10:57:28 PM UTC
I created some simple/crude Insert, Update and Delete extensions for Dapper for those that want to have a look. Code available on my blog at http://weblogs.asp.net/jdanforth/archive/2011/05/11/refactored-dapper-extensions.aspx

Cheers,
Johan
Friday, May 27, 2011 1:03:37 PM UTC
I'm wondering about the syntax you're showing for the Massive Micro-ORM in this blog-post.

Is this the right syntax: args: 5,20

Or did you mean: args: new object[] { 5, 20 }

I can't see how the former syntax would be declared in order to work like that. Could you elaborate?
Friday, May 27, 2011 5:24:45 PM UTC
Lasse - I copy pasted that from a Rob Conery blog post. Has it changed?
Friday, June 03, 2011 10:15:10 AM UTC
It's just that I don't understand how that can work, see: http://stackoverflow.com/questions/6145685/how-did-they-implement-this-syntax-in-the-massive-micro-orm-multiple-args-parame
Wednesday, June 22, 2011 5:32:41 AM UTC
If you're not writing your own SQL, your SQL sucks. Guaranteed.

ORM should never be used except for prototyping. Or if you just don't care about performance or data design at all.
Wednesday, June 22, 2011 7:31:38 AM UTC
Noah,

That is a rather strong statement, would you say that if you are not writing your own IL all C# code sucks?

Abstractions leak performance, it is inevitable. Sometimes the leak is not noticeable and the benefit far outweighs the cost.

I agree that often ORMs generate ungodly SQL, however ... in many cases they generate fine SQL and you win on the productivity front.

My advice would be: "understand your tools and their performance characteristics"
Wednesday, July 13, 2011 3:05:27 PM UTC
Listened to this podcast last night, implemented Dapper and pointed my Repository interfaces to the new code of my research project. Initial PT results show ~3% higher response time and around 70% less code (I use data readers). Entire implementation took about 4 hours. I am worried about resource utilization; however.

In a nutshell --> PHENOMENAL product. Looking to test out Massive as well when I get time but I'm sold!
DimitryU
Wednesday, October 19, 2011 2:40:05 PM UTC
Scott, although I love this library, I see a couple of things that worry me as it relates to MVC and razor. The first is typing my model as dynamic. Since I can't use dynamics in lambda expressions, I lose all the nice built in html helpers in MVC 3. Additionally, I would assume the examples above are just for illustration and you wouldn't advocate placing this sort of data retrieval logic in the presentation layer in an enterprise application. Do you have any thoughts on either topic? Thanks for all the great work!
Jonathan McPhail
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.