core-admin icon indicating copy to clipboard operation
core-admin copied to clipboard

(floats) InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Single', but this ViewDataDictionary instance requires a model item of type 'System.String'.

Open joepperkins opened this issue 10 months ago • 2 comments

Any Entity property of type float causes the exception below

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Single', but this ViewDataDictionary instance requires a model item of type 'System.String'.

Steps to reproduce:

  1. Add the property below to DotNetEd.CoreAdmin.DemoApp.Models.TestEntity public float TaxRate { get; set; }
  2. Edit the TestEntity from the UI and throws an exception

joepperkins avatar Jan 05 '25 09:01 joepperkins

The implemented fix was to decorate the float property with [DataType(DataType.Text)] and the backend will catch any validation issues.

[DataType(DataType.Text)] public float TaxRate { get; set; }

joepperkins avatar Jan 05 '25 11:01 joepperkins