I have a table that references a child table (one to many) where they both derive from AuditBase and use [AutoApply(Behavior.AuditCreate)] on the Create DTO’s.
When sending a create DTO for the parent table, and have the child DTO list populated, when it tries to create the child row, it’s not populating all the Audit fields on that child table.
I’m getting this error:
23502: null value in column “created_by” of relation “schedules” violates not-null constraint
where schedules is the referenced table. Does AutoQuery actually use the CreateSchedule DTO where [AutoApply(Behavior.AuditCreate)] attribute is? Or how would it go about filling in the audit fields for that child table?
`[ValidateIsAuthenticated]
[AutoApply(Behavior.AuditCreate)]
[Route("/treatments", "POST")]
public partial class CreateTreatments :
IReturn<IdResponse>, IPost, ICreateDb<Treatments>
{
...
[Reference]
public List<Schedules>? Schedules { get; set; }
... `
` [ValidateIsAuthenticated]
[AutoApply(Behavior.AuditCreate)]
[Route("/schedules", "POST")]
public partial class CreateSchedules
: IReturn<IdResponse>, IPost, ICreateDb<Schedules>
{
...`
And then the actual POCO:
`public partial class Schedules : AuditBase
{
[PrimaryKey]
[AutoId]
public Guid Id { get; set; }
...
[References(typeof(Treatments))]
public Guid? TreatmentId { get; set; }
...`
And the parent table POCO:
public partial class Treatments : AuditBase
{
[PrimaryKey]
[AutoId]
public Guid Id { get; set; }
...
[Reference]
public List<Schedules>? Schedules { get; set; }
}