4 ms·
Dapper.NET - "micro-ORM" that poweres StackOverflow goes opensource
- jeswin 16y agoWe have an open source ORM here: http://www.agilefx.org http://www.agilefx.org. Sits on top of Linq-To-Sql and adds features found in Entity Framework. Looking for contributors.
- patja 16y agoI 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?
- singular 16y agoInteresting 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.
- bad_user 16y agoI don't see code-generation; what are you referring to?
- singular 16y agoI mean dynamic code generation at runtime, rather than actually outputting text :-) E.g. CreateParamInfoGenerator() at line 208.
- bad_user 16y agoYes, 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.
- arethuza 16y agoIt looks like it is using the Reflection Emit capabilities of .Net: http://msdn.microsoft.com/en-us/library/8ffc3x75.aspx http://msdn.microsoft.com/en-us/library/8ffc3x75.aspx
- kenjackson 16y agoLooking 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.
- darrenkopp 16y agoit's an optimization so that you don't die from the reflection cost.
- kenjackson 16y agoOK, I buy that.
- glhaynes 16y agoI assume they've tested it out and aren't just assuming that the reflection would be a killer... but...
- gokhan 16y agoRelated blog post: http://samsaffron.com/archive/2011/03/30/How+I+learned+to+stop+worrying+and+write+my+own+ORM http://samsaffron.com/archive/2011/03/30/How+I+learned+to+st... Another framework in the same direction is Rob Connery's Massive: http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-mas...
- mooftard 16y agoAll those strings look hard to maintain and refactor. You won't know that your query is broken until you run it. That makes it of very little value despite any supposed merits.
- singular 16y agoThe 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+stop+worrying+and+write+my+own+ORM http://samsaffron.com/archive/2011/03/30/How+I+learned+to+st...
- sajidnizami 16y agoGap 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.
- jph00 16y agoNo, 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.
- sajidnizami 16y agoSorry. My mistake. :)
- mdemare 16y agoPlease fix typo in title (poweres).
- jitbit 16y agoSorry, can't. The editing is gone hours ago. Apologies for the typo.
- drylight 16y agoIf 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 https://github.com/dbarros/dapper-dot-net
- dustingetz 16y agoone click http://code.google.com/p/dapper-dot-net/source/browse/SqlMapper.cs http://code.google.com/p/dapper-dot-net/source/browse/SqlMap...
- d4nt 16y agoI 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.
- mquander 16y agoI 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.
- SigmundA 16y agoLocks 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.
- nberardi 16y agoMy 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 https://github.com/managedfusion/dapper-dot-net
- moron4hire 16y agoI did something somewhat similar to this and have been iterating it for several years http://sqlsiphon.codeplex.com/ 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.