-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Description
I have a problem with SQL Server time type. SQLProvider is mapping this type to DateTime but per SQL Server Data Type Mappings it should be mapped to TimeSpan. When I try to select column of time type I get System.InvalidCastException.
System.InvalidCastException
HResult=0x80004002
Message=Object must implement IConvertible.
Source=mscorlib
StackTrace:
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at FSharp.Data.Sql.Common.SqlEntity.GetColumn[T](String key)
at XYZ.DataAccess.load@49.Invoke(SqlEntity trip)
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc2 mapping, FSharpList1 x)
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc2 mapping, FSharpList1 list)
Repro steps
- Create table with column of time type
- Try to load data of this column with SQLProvider -> System.InvalidCastException
Known workarounds
I have forked repo and changed type for time to TimeSpan and everything works fine. Change is visible here.
getDbType:
if providerType = 31
then p.SqlDbType <- SqlDbType.DateTime
else if providerType = 32
then p.SqlDbType <- SqlDbType.Time
mappings:
else if oleDbType = "time"
then typeof<TimeSpan>.ToString()
I can create PR for this but I don't know if this is general solution for all SQL server versions.
Related information
I am using Microsoft SQL Azure (RTM) - 12.0.2000.8