Two strange things happened today:
- I got an error when trying to update a model through AutoQuery:
String or binary data would be truncated in table ‘StepsStage.dbo.CrudEvent’, column ‘RequestBody’.
It’s pretty obvious that the varchar(8000) limit was hit here. How can I make this larger, or accept truncation? Right now it crashes. (For now I’ve manually changed the data type in SQL Server)
- I have no idea why the CrudEvent was turned on for this data model. I’ve used it for a different datamodel, using the
[AutoApply(Behavior.AuditCreate)]
on the DTO, but not for this.
Here’s the DTO used for this query:
[ValidateHasPermission(Permissions.WriteFormDefinition)]
[Route("/formdefinitions/{Id}", Verbs = "PUT")]
public class UpdateFormDefinition : FormDefinition, IUpdateDb<FormDefinition>, IReturn<UpdateFormDefinitionResponse>
{
//...
FormDefinition is my type, and it is a POCO with no inheritance, defined like this:
[UniqueConstraint(nameof(Name), nameof(Version))]
public class FormDefinition
// ...
In my Configure.AutoQuery.cs I have not added anything “include all” or anything like that:
public class ConfigureAutoQuery : IConfigureAppHost, IConfigureServices
{
public void Configure(IAppHost appHost)
{
appHost.Plugins.Add(new AutoQueryFeature {
MaxLimit = 2000,
IncludeTotal = true,
});
// Create CrudEvent table if it doesn't exist
appHost.Resolve<ICrudEvents>().InitSchema();
}
public void Configure(IServiceCollection services)
{
services.AddSingleton<ICrudEvents>(c =>
new OrmLiteCrudEvents(c.Resolve<IDbConnectionFactory>()));
}
}
My Service class (since I’m overriding some):
[Authenticate]
[RequiredRole("Admin", ApplyTo = ApplyTo.Post | ApplyTo.Put)]
public class FormDefinitionServices : Service
{
public FormRepository formRepo { get; set; }
public IAutoQueryDb AutoQuery { get; set; }
// AutoQuery/AutoCRUD doesn't have one for single (only query)
public FormDefinition Get(SingleFormDefinition request)
{
return formRepo.GetFormDefinition(request.Id);
}
public FormDefinitionsResponse Get(SearchFormDefinitions request)
{
}
So the two questions are:
- Is it possible to configure CrudEvent to use a larger RequestBody column by default?
- Any idea why I got the CrudEvent/Audit stuff on the FormDefinition class?