Skip to content

Make Dapper call GetFieldValue<T> instead of GetValue #1644

@ghost

Description

Hello,

I am using the NodaTime Plugin of Npgsql and it implements "NodaTime.Instant" as the Default Type for timestamptz.
In addition it also provides the possibility to get a "NodaTime.ZonedDateTime" by calling GetFieldValue<T>.

https://www.npgsql.org/doc/types/basic.html
https://www.npgsql.org/doc/types/nodatime.html

Currently when we defined a class like that:
public class TestData
{
public ZonedDateTime TheTime { get; set; }
}

and try to load some data into it by calling:

c.Query<TestData>(@"select now() as the_time;").FirstOrDefault()

An exception is raised:

Unable to cast object of type 'NodaTime.Instant' to type 'NodaTime.ZonedDateTime'.

When we use Npgsql directly and call GetFieldValue<T> the ZonedDateTime mapping works perfectly.
Is there any way to get this to work with Dapper beside modifying the Npgsql.NodaTime Plugin?

Thanks,
michael

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions