Dzoukr / Dapper.FSharp

Lightweight F# extension for StackOverflow Dapper with support for MSSQL, MySQL, PostgreSQL, and SQLite
MIT License
365 stars 35 forks source link

Does Dapper.FSharp support records when using QueryAsync? #59

Closed Jmaharman closed 2 years ago

Jmaharman commented 2 years ago

This is mostly a clarification post, rather than requesting any functionality.

On the readme it says this supports "Support for F# records / anonymous records", but I'm not sure if that is limited to the CE builder stuff, or if it includes QueryAsync.

When I use connection.QueryAsync(mySqlText, myParams) I can get anonymous records to work no problem, but an F# record gives me the no parameterless constructor found.

Is this expected, or have I messed something up?

Thanks for the great library, and your time reading this post.

TerenceHinrichsen commented 2 years ago

I get that error "ALOT" using FSharp records, but it is very likely that you have either a datatype or field name mismatch. Just check your schema again. :) Good luck!

TerenceHinrichsen commented 2 years ago

Also check that you have registered any "Option" types - if you have options in your record.

Jmaharman commented 2 years ago

Thanks @TerenceHinrichsen, I'll make sure I do that!

Dzoukr commented 2 years ago

Thanks, @TerenceHinrichsen, for clarification. I don't see any other steps to take - make sure your columns are 1:1 with anonymous records + properties are named same as in DB table.

Dzoukr commented 2 years ago

Sorry, just hit wrong button 😄 (oh, mornings...)

Jmaharman commented 2 years ago

ah I've got it, it was the order of the parameters in the constructor. Interesting this wasn't a problem for the anonymous record.

Has anyone got any recommendations when using records and Dapper's QueryAsync and my own SQL? I'm a bit worried of the flakeyness of it if someone changes the ordering of a property / SQL statement.