Given the following table
in my database (PostgreSQL)
CREATE TABLE produkt (
id SERIAL NOT NULL,
name VARCHAR(50),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now())
);
ALTER TABLE produkt ADD CONSTRAINT produkt_pkey PRIMARY KEY (id);
I want to use NPoco to access the data using this poco
[TableName("produkt"), PrimaryKey("id", AutoIncrement = true)]
public class Product
{
[Column("id")]
public int Id { get; set; }
[Column("name")]
public string Name { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
}
Now, when I call
var product = new Product
{
Name = "My new Product"
};
Database.Insert(product); // or Database.Save<Product>(product);
The created_at
-column is -infinity
, even though the default
value has been declared. Is there any way to fix this? One alternative would be to set the Date within the application, but I would rather have this functionality beeing realized using the default
value in the DB.
Nullable<DateTime>
as well asDateTime?
, but neither did the trick. Maybe it is a Postgre Issue. Setting the Date in the CTor would be an Alternative I know, but I would prefer setting it in the DB to stay consistent. Anyway, thank you very much! – Fete