Hi,
I've added some properties dynamically in the Tenant form. But, for the boolean fields, if the user don't tick then, when saving the form it says that the field is mandatory. The user has to tick and untick the field to be able to save. It seems that the default value is null, but my property is non-nullable.
Framework: Blazor WASM version 4.3.2
6 Answer(s)
-
0
Hello there,
I wrote the necessary codes to reproduce the problem. But it worked fine for me. You can find the codes I wrote to test below;
I updated the
MyProjectNameEfCoreEntityExtensionMappingsclass in theMyProjectName.EntityFrameworkproject.public static class MyProjectNameEfCoreEntityExtensionMappings { private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); public static void Configure() { MyProjectNameGlobalFeatureConfigurator.Configure(); MyProjectNameModuleExtensionConfigurator.Configure(); OneTimeRunner.Run(() => { ObjectExtensionManager.Instance .MapEfCoreProperty<Tenant, Boolean?>( "IsCheck", (entityBuilder, propertyBuilder) => { propertyBuilder.HasDefaultValue(null); } ); }); } }Note: Maybe this step is not necessary for you. Note: This class can be used to map extra properties to table fields in the database. So don't forget to add migration and update the database.
Open the
MyProjectNameDemoModuleExtensionConfiguratorin theMyProjectName.Domain.Sharedproject, and I changed the contents of theConfigureExtraPropertiesmethod as shown below:private static void ConfigureExtraProperties() { ObjectExtensionManager.Instance.Modules().ConfigureSaas(saas => { saas.ConfigureTenant(tenant => { tenant.AddOrUpdateProperty<Boolean?>( "IsCheck", options => { options.DefaultValue = null; } ); }); }); }Result
Please let me know if the solution worked for you :)
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0
This is a bug, we will fix it. by the way, ticket refunded : )
For now, can you try the code below;
tenant.AddOrUpdateProperty<Boolean>( "IsActive", options => { options.Attributes.Clear(); } );Please let me know if it works in your case.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi berkansasmaz,
Yes, your workaround worked! Do I need to remove that when the fix is released or I can leave there?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Actually, it's up to you, but I suggest you remove it. Because team members reading the code may have difficulty understanding why that code is there.
By the way, you can see the fix made here
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

