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 get date type field from DB. #2190

Open
cratu opened this Issue Oct 16, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@cratu

cratu commented Oct 16, 2018

Steps to reproduse.

Try to get any column with not null date type value.

Issue details

When I tryed to get date (date type) value from DB I got an error:

Exception message:
The field 'speriod' has type 'date', which is currently unknown to Npgsql. You can retrieve it as a string by marking it as unknown, please see the FAQ.

Further technical details

Npgsql version: 4.0.3
PostgreSQL version: 9.6
Operating system: Windows 2012x64
.Net: 4.5.1

Other details about my project setup:
When I change type to timestamp everything is working Ok.
Enabling Noda Time has no effect at all, the same error.

@roji

This comment has been minimized.

Member

roji commented Nov 18, 2018

Sorry for taking so long to answer.

It's difficult to help without any sort of actual code sample which demonstrates what you're trying to do. The following works as expected:

using (var cmd = new NpgsqlCommand("CREATE TEMP TABLE foo (mydate date); INSERT INTO FOO (mydate) VALUES ('2018-03-01')", conn))
    cmd.ExecuteNonQuery();

using (var cmd = new NpgsqlCommand("SELECT * FROM foo", conn))
using (var reader = cmd.ExecuteReader())
{
    while (reader.Read())
    {
        Console.WriteLine("Date: " + reader.GetFieldValue<DateTime>(0));
    }
}

Please post a minimal console app which demonstrates the issue.

@cratu

This comment has been minimized.

cratu commented Nov 23, 2018

Ok, thanks for the answer. I'll try to reproduse bug with small app.

@cratu

This comment has been minimized.

cratu commented Nov 23, 2018

Can't reproduce on simple console app, I will search for diferences with main project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment