Is there any general guidance on what Visual Studio project property settings should not be changed for Radzen projects?
I made the mistake of changing the Nullable project setting (Build > General) to "Enable" in Visual Studio (Radzen created it as blank).
I started getting exceptions in the following circumstances:
- In my SQL Server database, a string (nvarchar) column in a table is defined as accepting nulls.
- The table concerned actually had some nulls in the column.
When the table was read and enumerated e.g. for a RadzenDataGrid, a run time exception would be raised.
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
at Microsoft.Data.SqlClient.SqlBuffer.get_String()
...
The exception seemed to occur because the column property (generated by EF scaffolding in "Models\<db>\<table>.cs
") was not defined as nullable, i.e. it had
public string Title {get;set;}
instead of
public string? Title {get;set;}
(This only applied to strings - other column types were defined as nullable, if they accepted nulls in the database e.g. "int?
".) If I edited the generated context column property to "string?
" it worked. But obviously one should not edit a generated file. So I initially thought this was a bug. However an app generated in Radzen from scratch using the same database did not show this problem.
Eventually I found that setting Nullable=Disable - none of the other available values works - allows the data source to be read OK in the above circumstances.
Note: Setting Nullable=Enable before generating the DataSource does not change the behaviour.
I wonder if there are any other settings that it would be wise to avoid changing?