admin管理员组文章数量:1356825
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!
本文标签:
版权声明:本文标题:c# - Handling TimeSpan type conversion issue in .NET 8 with Fluent NHibernate after migrating from .NET Framework - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744069447a2585619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论