News for hackers. Stuff that matters.
Re:What ORMs have taught me: just learn SQL (2014) by bunderbunder on Sunday June 26, 2016 @03:55PM (#11982391)
On C#, Dapper's useful, but not perfect, for letting you write your own queries and then making it easy to unpack the result sets.

Unfortunately, it relies on property setters for doing the unpacking, so it doesn't interact super well with your code if you like to avoid unnecessary mutability.

The only publicly-available lightweight ORM I know of that does a good job with that is the SQL type provider in F#.Data. That one is head-and-shoulders above any other option I've found for working with databases. It does require that you write your data access layer in F#, though, which may make it a hard one to sell at work.

Re:What ORMs have taught me: just learn SQL (2014) by tfigment on Sunday June 26, 2016 @04:29PM (#11982536)
Thanks. That actually doesn't look that bad. It would be nice to have anonymous type objects but I recognize the difficulty in that. This looks like a nice compromise. Now if they could also fix passing in arrays as part of a parameterized query "select x from y where z in ?" where ? is a collection of strings or integers it would be perfect but I think that is a driver/interface problem.

Edit: Looks like it actually does says it does support the enumerable but I'm questioning if it will do what I want. Will have to test out but I'm guessing there is a limit to the size of the array.

Re:What ORMs have taught me: just learn SQL (2014) by bunderbunder on Sunday June 26, 2016 @05:49PM (#11982930)
Dapper accepts anonymous objects for passing query parameters. It will return an expando if you don't specify the type of object you want back, too. That can be convenient, but I don't personally like having dynamic objects running too wild in my code so I end up manually mapping it to another type before returning anyway. (AutoMapper can help here.)

The IEnumerable support will generate (parameterized, I believe) inline arrays in the query. Not really my favorite, but it works.

The thing that I couldn't get over, and which ultimately led me to write my own micro-ORM at my last job, was the weak support for table-valued parameters. But I gather they've fixed that since then, so hopefully it's not a big deal anymore.

Re:What ORMs have taught me: just learn SQL (2014) by deanward81 on Sunday June 26, 2016 @05:14PM (#11982757)
Dapper supports IN statements being passed an array:

SELECT x, y FROM A WHERE z IN @ids

Works if you pass in a parameters object containing a property called ids that is a list/array of some sort (see https://github.com/StackExchange/dapper-dot-net#parameterize...).

On SQL 2016 this uses STRING_SPLIT across an nvarchar(MAX) which makes it effectively unbounded. Earlier versions and other platforms have restrictions on the number of elements in the array/list.

Re:What ORMs have taught me: just learn SQL (2014) by deanward81 on Sunday June 26, 2016 @05:09PM (#11982734)
Dapper will use a constructor with parameter names that match your query's columns if you need immutability.