-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Enum Invalid cast from 'System.Int64' (works without AOT) #92
Labels
bug
Something isn't working
Comments
Definitely needs fixing, thanks - will get it done |
Invalid cast exception also happens when mapping from string
|
This also happens when querying a column in SQL Server defined as tinyint or smallint and attempting to map to enum, whereas non-AOT works. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following create statement with an Enum in the class will fail with Invalid cast from 'System.Int64'.
I´m using sqlite, the query that fails looks like this
The Enum is mapped to an INTEGER column in Sqlite. Without AOT the mapping works just fine.
Adding a TypeHandler like this does not seem to work either
I am aware that this query in particular parsing the enum would be avoidable entierly, because I only need the Id back, but this would just be a fix for this one query and it would still be an issue for virtual everything else. It just happens to be the first thing that runs in virtually every single test I have.
There is this issue for regular dapper DapperLib/Dapper#259
So, does that mean if dapper AOT does not handle enums out of the box it just won´t be possible to make it work? I could probably work around this with a class that imitates enums and some explicit converters, but I would rather not.
Tried to create a simple wrapper class like this
with this type converter
Also does not work throws
No mapping exists from object type UserRoleColumn to a known managed provider native type
in the same place.On further inspection
SqlMapper.AddTypeHandler
is not yet AOT friendly. It breaks on publish so wether it´s used or not by the code generated does not even matter because you can´t register them.The text was updated successfully, but these errors were encountered: