-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeHandler is not called for parameterised constructor #461
Comments
…nning on SQL-Server - needs to be changed to SQLite to repro
Thanks; I've pulled it in as an initial test, but haven't repro'd yet, due to SQL-Server talking natively in datetimeoffset, and SQLite not working properly on DNX451 (my test rig targets DNX451). Will evolve this (probably using a completely artificial test type) and see if we can get it working. The fun question will probably be around constructor resolution - i.e. how does that happen reliably (by name? by type?). Those are questions that can be deferred a bit when using properties / fields, but for a constructor, for example, there could be 3 constructors - choosing between them when none is an exact match and all 3 would require (say) 1 conversion... could be fun. Might need the caller to implement a custom |
I would have thought if there is an ambiguous constructor, it would just throw. Trying to infer the constructor precedence based on TypeHandlers/Maps/Whatever would easily lead to some very confusing scenarios, and given this issue seems to have gone undetected, it doesn't seem to be overly important? |
Indeed, I'm mostly aiming for "make it work". I have a spike on my local
|
Should be fixed next build, but if you happen to be able to build locally and check it, I'd be eager to hear how it goes |
This is in 1.50.0-beta8 (the "beta" here is just because it includes the DNX targets, which is technically RC1). https://www.nuget.org/packages/Dapper/1.50.0-beta8 |
Awesome, haven't had chance to try it out yet, but will hopefully get round to it today. Thanks, really quick turnaround too 😄 |
…e issue: DapperLib#718). It implements the method suggested by numerous other users but leaves the byte order (endian) to the .net layer. It also fixes the guid equivalent issue raised in DapperLib#461.
We've had to create a TypeHandler to handle DateTimeOffset because SQLite has no concept of date/time, so it is saved as a string, which is fine. When querying the data back out, the
Parse
method is only called if it is being serialised to a type with a parameterless constructor. If a constructor exists which initialises all the properties the type handler is not called, which results in a "InvalidOperationException" with the followingNote how it is looking for SomeDateValue to be a string still.
I'm not sure if I'm explaining this the best way, I haven't been using Dapper for very long, so this may not be the best way of solving this problem. Below is a small, reproducible example using an in memory SQLite database.
The text was updated successfully, but these errors were encountered: