Can someone help me? I'm encountering an issue with the TimeSpan
datatype in .NET 8 using FluentNHibernate.Mapping
.
To summarize, my project was initially on .NET Framework 4, and I recently migrated it to .NET Core 8. However, all the fields in my entities that were of type TIME
now return the following error in the SQL result:
System.FormatException: Input string '07:30:00' was not in the correct format.
System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.TimeSpan'.
Even after changing the type of the variable in the entity class to TimeSpan
, the error persists but with a slightly different message:
System.FormatException: Input string '07:30:00' was not in the correct format.
System.InvalidCastException: Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.
I have already tried using .CustomType<TimeAsTimeSpanType>()
and implemented a custom converter for JSON deserialization, but when I run a dynamic SQL query with a generic return (e.g., IList<dynamic>
), this error occurs.
Does anyone know another way to handle the TIME
datatype while still using FluentNHibernate
?
Additional information for context:
- PostgreSQL database:
- Column type:
TIME
Code in my C# entity:
public virtual TimeSpan column_time { get; set; }
Class mapping:
Map(x => x.column_time).Column("column_time")
.CustomType<TimeAsTimeSpanType>();
Let me know if anything else is needed or if there are further issues!