ServiceStack 8.2.2 Autoquery crud delete is not working for me as expected.
These are my classes:
public class Company : AuditBase
{
[AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
[Reference]
public CompanyDetails CompanyDetails { get; set; }
[Reference]
public List<Employee> Employees { get; set; }
[Reference]
public List<ApplicationUserCompany> ApplicationUserCompanies { get; set; }
}
public class CompanyDetails : AuditBase
{
[AutoIncrement]
public int Id { get; set; }
[References(typeof(Company))]
public int CompanyId { get; set; }
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
}
[ValidateIsAdmin]
[AutoApply(Behavior.AuditCreate)]
public class CreateCompany : ICreateDb<Company>, IReturn<IdResponse>
{
public string Name { get; set; }
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
[Input(Type = Input.Types.Tag)]
public List<string> ApplicationUserIds { get; set; }
}
[ValidateIsAdmin]
[AutoApply(Behavior.AuditModify)]
public class UpdateCompany : IUpdateDb<Company>, IReturn<Company>
{
public int Id { get; set; }
public string Name { get; set; }
public CompanyDetails CompanyDetails { get; set; }
}
[ValidateIsAdmin]
[AutoApply(Behavior.AuditDelete)]
public class DeleteCompany : IDeleteDb<Company>, IReturnVoid
{
public int Id { get; set; }
}
[ValidateIsAdmin]
[AutoApply(Behavior.AuditCreate)]
public class CreateCompanyDetails : ICreateDb<CompanyDetails>, IReturn<IdResponse>
{
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
[References(typeof(Company))]
[ValidateNotNull]
public int CompanyId { get; set; }
}
and my setup
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services =>
{
// Enable Audit History
services.AddSingleton<ICrudEvents>(c =>
new OrmLiteCrudEvents(c.GetRequiredService<IDbConnectionFactory>()));
services.AddPlugin(new AutoQueryDataFeature());
services.AddPlugin(new AutoQueryFeature
{
MaxLimit = 1000,
//IncludeTotal = true,
});
})
.ConfigureAppHost(appHost =>
{
appHost.Resolve<ICrudEvents>().InitSchema();
});
I can use CreateCompany to create a company via API/Locode fine but when I hit DeleteCompany nothing happens apart from a delete audit event being created. The deleted date or deleted by are not set. I am not exactly sure after reading docs if softdelete should be default. I assumed softdelete only happens if its specified and hard delete otherwise.
No errors are returned and I am able to delete directly from database without any issue. Audit events created correctly but nothing updated on main record to indicate it has been deleted. I just tested also with a simple class with no relationships and same behaviour.
Am I missing something?