-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Can't map null value to non-nullable property (which is nullable) #29
Comments
Hi, there are some limitations to the mapping of the nullable arrays, described here: https://vb-consulting.github.io/norm.net/docs/reference/read/#arrays-and-enums I believe you can mitigate those limitations by using DbReader callback: Also, reference here: https://vb-consulting.github.io/norm.net/docs/reference/methods/#withreadercallback But unfortunately, the DbReader callback isn't that elegant and straightforward. |
Hi @vbilopav, Thanks for the quick response. Seems like the quick workaround is indeed to use the var account = await connection.WithReaderCallback( p =>
{
// resolve as null
if ( p.Reader.IsDBNull( p.Ordinal ) )
{
return DBNull.Value;
}
return null;
} )
.ReadAsync<Account>( sql, parameters )
.FirstOrDefaultAsync(); Although it seems like this is something that could easily be supported, since all I'm doing in the callback is to check if the value is For the time being, I don't mind using this workaround, since I'll probably need it for |
It's not easily supported. I've tried, and it's extremely difficult, given the current approach. It would have required me to rewrite everything from scratch. |
Not worth the trouble then, I'd say. |
Hi,
I'm seeing the following mapping error
Except that the
Claims
property is actually nullable, so the mapping should have worked I think.The
claims
field in the database is an array and it isNULL
at this point, yes.In the same way, the class property is a nullable array
Am I missing something?
The text was updated successfully, but these errors were encountered: