You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to insert an object into my database. It succesfully inserts the row but then it crashes immediately afterwards when it tries to return the primary key.
The reason is that one of the columns of the primary key is an enum and it fails to map it from int in the database to enum in c#:
connection.Insert(metatabell);
I have managed to work around this temporarily by only returning the identity which is null in my case
System.InvalidCastException: Invalid cast from 'System.Int32' to 'Common.MetatabellType'.
at System.Convert.DefaultToType(IConvertiblevalue,TypetargetType,IFormatProviderprovider)
at RepoDb.Converter.ToType[T](Objectvalue)
at lambda_method7(Closure,Object,Object)
at RepoDb.DbConnectionExtension.InsertInternalBase[TEntity,TResult](IDbConnectionconnection,StringtableName,TEntityentity, IEnumerable`1fields,Stringhints, Nullable`1commandTimeout,StringtraceKey,IDbTransactiontransaction,ITracetrace,IStatementBuilderstatementBuilder)
at RepoDb.DbConnectionExtension.InsertInternal[TEntity,TResult](IDbConnectionconnection,StringtableName,TEntityentity, IEnumerable`1fields,Stringhints, Nullable`1commandTimeout,StringtraceKey,IDbTransactiontransaction,ITracetrace,IStatementBuilderstatementBuilder)
at RepoDb.DbConnectionExtension.Insert[TEntity](IDbConnectionconnection,TEntityentity, IEnumerable`1fields,Stringhints, Nullable`1commandTimeout,StringtraceKey,IDbTransactiontransaction,ITracetrace,IStatementBuilderstatementBuilder)
Bug Description
I try to insert an object into my database. It succesfully inserts the row but then it crashes immediately afterwards when it tries to return the primary key.
The reason is that one of the columns of the primary key is an enum and it fails to map it from int in the database to enum in c#:
I have managed to work around this temporarily by only returning the identity which is null in my case
Exception Message:
Schema and Model:
I use entity framework for generating the database and created the primary key from the type and the version:
This is what it looks like in the database:
Library Version:
Example: RepoDb v1.13.2-alpha1 and RepoDb.SqlServer v1.13.2-alpha1
The text was updated successfully, but these errors were encountered: