News for hackers. Stuff that matters.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by gokhan on Tuesday April 05, 2011 @04:37AM (#2410173)
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by singular on Tuesday April 05, 2011 @04:57AM (#2410223)
The ORM is definitely very read-focused, which is probably not that surprising given that it's used for web, and given the motivations for creating it, discussed at the blog post mentioned by @gokhan [1].

It would be nice to have some lightweight stuff for updating/inserting too, though I guess doing it in such a way that you don't need to write lots of boilerplate kinda requires SQL generation, which dapper is avoiding on purpose.

[1]: http://samsaffron.com/archive/2011/03/30/How+I+learned+to+st...

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by singular on Tuesday April 05, 2011 @04:32AM (#2410162)
Interesting use of code generation - pretty cool, oft unused part of .net/C#. Also interesting how it's designed to be a drop-in single C# file, that often seems the easier way of getting functionality into a project, side-stepping DLL version issues.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by kenjackson on Tuesday April 05, 2011 @11:04AM (#2411193)
Looking at the dynamic code gen... is it necessary? Can't they just use a method that takes 'type' and the set of properties as arguments? I'm sure I'm missing something, but don't see it at the moment.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by darrenkopp on Tuesday April 05, 2011 @11:37AM (#2411341)
it's an optimization so that you don't die from the reflection cost.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by kenjackson on Tuesday April 05, 2011 @11:42AM (#2411361)
OK, I buy that.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by glhaynes on Tuesday April 05, 2011 @03:23PM (#2412328)
I assume they've tested it out and aren't just assuming that the reflection would be a killer... but...
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by bad_user on Tuesday April 05, 2011 @04:52AM (#2410207)
I don't see code-generation; what are you referring to?
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by singular on Tuesday April 05, 2011 @04:53AM (#2410210)
I mean dynamic code generation at runtime, rather than actually outputting text :-)

E.g. CreateParamInfoGenerator() at line 208.

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by bad_user on Tuesday April 05, 2011 @06:16AM (#2410368)
Yes, you're right. It's pretty cool.

Also, if you're looking for other cool samples, there's a chapter in "Beautiful Code" by Charles Petzold you may find interesting.

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by arethuza on Tuesday April 05, 2011 @05:39AM (#2410297)
It looks like it is using the Reflection Emit capabilities of .Net:

http://msdn.microsoft.com/en-us/library/8ffc3x75.aspx

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by moron4hire on Tuesday April 05, 2011 @01:02PM (#2411700)
I did something somewhat similar to this and have been iterating it for several years http://sqlsiphon.codeplex.com/

I find it interesting that they support text SQL queries, as that was a feature I explicitly left out. My library is about minimizing the amount of repetition in code while supporting calls to stored procedures.

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by nberardi on Tuesday April 05, 2011 @10:59AM (#2411176)
My biggest problem with Dapper was the lack of MySQL support, so I updated it to work with all databases by going the ADO.NET only route. You can find my work here:

https://github.com/managedfusion/dapper-dot-net

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by drylight on Tuesday April 05, 2011 @08:48AM (#2410692)
If you hang out on github, and do your social coding over there (or simply prefer git over Mercurial), here is a github fork of the repository: https://github.com/dbarros/dapper-dot-net
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by dustingetz on Tuesday April 05, 2011 @10:23PM (#2413662)
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by sajidnizami on Tuesday April 05, 2011 @05:22AM (#2410268)
Gap of about 20ms between compiled Linq2SQL and this looks enticing. I guess this can be used at hot spots with optimized SQL queries using existing LINQ2SQL entities.

Definitely not for everyone. The whole reason it exists perhaps is to kill SQL translation time and avoid dealing with data readers.

Kudos for making it OSS.

Also, Entity Framework takes about 800ms unoptimized. That is almost a second to execute a query. I can't begin to imagine what the performance of its solution would be in the hands of a new developer.

Edit: I misread about the EF performance. Sorry about that.

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by jph00 on Tuesday April 05, 2011 @05:37AM (#2410292)
No, EF is 800ms for 500 queries, not for 1 query. I've not seen EF overhead be a performance hotspot on projects I've been involved with.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by sajidnizami on Tuesday April 05, 2011 @05:42AM (#2410308)
Sorry. My mistake. :)
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by jeswin on Tuesday April 05, 2011 @07:57AM (#2410548)
We have an open source ORM here: http://www.agilefx.org. Sits on top of Linq-To-Sql and adds features found in Entity Framework.

Looking for contributors.

Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by patja on Tuesday April 05, 2011 @11:25AM (#2411292)
I don't get it. Sits on top of a dead product and adds features from another product that already exists. Who is the market? the ABM crowd?
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by d4nt on Tuesday April 05, 2011 @09:13AM (#2410762)
I notice this is using data readers. I'm not an expert but I believe they keep the connection (and therefore any database locks) until you've finished processing and closed the reader. Given that it's for hydrating strongly typed collections into memory you aren't going to be ignoring any records. You might get even better throughput at the database (at the expense of memory usage in the app) by using datasets which will run the query, then close the connection, then return all the results to the app.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by mquander on Tuesday April 05, 2011 @09:50AM (#2410894)
I strongly disagree. If you use a DataAdapter to populate a dataset, all it's doing is iterating over a reader internally and loading the results into the dataset. There's no reason it would ever be as fast, let alone faster, than using a reader yourself to populate a data structure that you actually want.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by SigmundA on Tuesday April 05, 2011 @10:39AM (#2411112)
Locks really shouldn't be happening with a datareader on a modern database with MVCC isolation (SQL2005+ and Oracle, etc.) unless you have specifically lowered isolation.
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by mdemare on Tuesday April 05, 2011 @05:49AM (#2410319)
Please fix typo in title (poweres).
Re:Dapper.NET - "micro-ORM" that poweres StackOverflow goes ... by jitbit on Tuesday April 05, 2011 @06:07AM (#2410351)
Sorry, can't. The editing is gone hours ago. Apologies for the typo.