I have a PetaPoco class that defines a database table. It looks like this:
namespace MyProject.Pocos { [TableName("AdminNotification")] [PrimaryKey("id", autoIncrement = true)] [ExplicitColumns] public class AdminNotification { [Column("id")] [PrimaryKeyColumn(AutoIncrement = true)] public int id { get; set; } [Column("dateTime")] public DateTime dateTime { get; set; } [Column("adminNotificationTypeId")] public int adminNotificationTypeId { get; set; } } }
It works fine, except for one. In the database table itself (in SQL Server Express), the default value for "dateTime" is set - by default it is (getdate()) . However, when a record is inserted using the PetaPoco class in my code, the dateTime value is always NULL.
How to set default value in PetaPoco class to current date / time?
Thanks!
source share