C#C
C#2y ago
SWEETPONY

Find doesn't return my collection

Shift contains a property: Qualifications
I'm trying to add them to Shifts and it works!
But when I get Shift using FindCoreAsync Qualifications in null
protected override async Task AddCoreAsync(Shift shift, EventHandlingContext context)
{
    shift.Created = timeProvider.GetUtcNow().DateTime;
    dbContext.Shifts.Add(shift);
        dbContext.ShiftQualifications.AddRange(shift.Qualifications!);
    await dbContext.SaveChangesAsync(context.CancellationToken).ConfigureAwait(false);
}

public override async Task<Shift?> FindCoreAsync(Shift shift, EventHandlingContext context)
{
    var foundShift = await dbContext.Shifts
       .AsNoTracking()
       .FirstOrDefaultAsync(
          s => s.ScheduledStart == shift.ScheduledStart
            && s.Type == shift.Type
            && s.ResourceId == shift.ResourceId,
            context.CancellationToken)
        .ConfigureAwait(false);

    return foundShift;
}
Was this page helpful?